这是我的代码
Directory.CreateDirectory(Directory.GetCurrentDirectory() + @"ExtractedContent");
using (StreamWriter sw = File.CreateText(Directory.GetCurrentDirectory() + @"ExtractedContent"))
{
sw.WriteLine($"TITLE: {extractedTitle[0]}");
sw.WriteLine("CONTENT:");
sw.Write(extractedContent[0]);
}`
错误:
未处理的异常:System.UnauthorizedAccessException:访问访问路径"C:\Users\"程序的目录"被拒绝。
问题是我没有给文件命名
using (StreamWriter sw = File.CreateText(Directory.GetCurrentDirectory() + @"ExtractedContentfile.txt(that's the solution)"))
{
sw.WriteLine($"TITLE: {extractedTitle[0]}");
sw.WriteLine("CONTENT:");
sw.Write(extractedContent[0]);
}