【发布时间】:2019-05-29 17:24:18
【问题描述】:
我正在创建一个 dotnet core 2.1 项目,当我尝试打开一个文件时出现此错误 System.IO.IOException,因为它在 netcoreapp2.1 下查找文件
class Program
{
static void Main(string[] args)
{
string path = "C:\user\name\desktop\file.txt";
FileStream file = new FileStream(path, FileMode.Open);
}
}
错误是
System.IO.IOException: The syntax of the file name, directory or volume is incorrect C:\Users\name\source\repos\app\app\bin\Debug\netcoreapp2.1\C:\user\name\Desktop\file.txt
【问题讨论】:
-
@John 这足以让你理解我的问题如果你想要更多,告诉我什么
-
@John 在一个简单的控制台应用程序 dotnet core 中尝试这 2 行在您的 VS 中
-
这给了我一个编译器错误。在 2.1 中使用绝对路径对我来说很好。这就是为什么我要求minimal reproducible example。