在类库 .NET Core 6 项目中保存文件

问题描述 投票:0回答:0

我想在文件夹中保存一些日志文件(

.txt
)。我如何从 .NET Core 6 项目中创建的类库中执行此操作?

我试过了,但没有任何反应,也没有抛出任何错误。刚刚添加到目录创建代码下方。还附上项目结构。

string targetFolderPath;

// First the session id
targetFolderPath = Root + "/" + "ABCLogs";

if (!Directory.Exists(targetFolderPath))
    Directory.CreateDirectory(targetFolderPath);

c# .net-core class-library
© www.soinside.com 2019 - 2024. All rights reserved.