c# - 找不到现有文件
问题描述
这是我的代码:
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'。
如果有人可以帮助我,谢谢。
解决方案
推荐阅读
- batch-file - 更改 Windows 启动命令的标题
- c# - 对象的反序列化给出错误:无法反序列化当前的 JSON 对象?
- c# - 用 C# 覆盖 FTP 服务器上已存在的文件时出现“(550)文件不可用”
- ios - 上传到itunesconnect并打开位码后找不到iOS应用程序主要目标符号文件
- html - 在 angular7 中,如何在显示项目列表时更改 mat-select 的高度?
- mysql - **当我执行此过程而不是得到错误 1064**
- entity-framework - 无法解析符号“ForSqliteHasDefaultValueSql”
- unit-testing - Vue Test Utils 中的“存根子组件”是什么?
- android - 如何在按钮单击时添加有限的编辑文本并获取数组中的所有编辑文本数据?
- html - 带有 2 个固定高度图像的 CSS 2 列布局