Mar*_*sen -1 c# system.io.file
标题中显示错误。我不知道为什么我要得到这个或我应该如何解决这个问题。Visual Studio在此行的标题中显示了错误:var f = System.IO.File.OpenRead(fil1);
class Program {
static void Main(string[] args) {
Stopwatch sw = Stopwatch.StartNew();
string fil1 = "C:\Users\mariu\Desktop\Jobboppgave\CaseConsoleApp\Prisfile.txt";
***var f = System.IO.File.OpenRead(fil1);***
int length = (int)(new System.IO.FileInfo(fil1).Length);
Run Code Online (Sandbox Code Playgroud)
您的路径不正确,因为您没有逃脱\。最快的方法是使用@:
string fil1 = @"C:\Users\mariu\Desktop\Jobboppgave\CaseConsoleApp\Prisfile.txt";
Run Code Online (Sandbox Code Playgroud)
重建您的项目,问题将得到解决。