首页 > 解决方案 > 找不到现有文件

问题描述

这是我的代码:

File.WriteAllText("combo_format.txt",File.ReadAllText("combo.txt").Replace(System.Environment.NewLine,""));
File.WriteAllText("combo_format.txt", File.ReadAllText("combo_format.txt").Replace("TEST", System.Environment.NewLine));
List<string> combo = new List<string>(File.ReadAllLines("combo_format.txt"));

在我运行程序之前,文件 combo_format 不存在。如您所见,我正在创建文件 combo_format 并将其文本存储到列表中。但是,在执行最后一行时出现此错误:

System.IO.FileNotFoundException:'找不到文件'C:\Users\Will\source\repos\txt sorter\txt sorter\bin\Release\netcoreapp3.1\combo_format'。

如果有人可以帮助我,谢谢。

标签: c#listfile

解决方案


推荐阅读