Could not find file ..\bin\Debug\content.dat

后端 未结 3 477
走了就别回头了
走了就别回头了 2021-01-19 12:14

I have added a file content.dat in my Visual Studio project at the same location where there is form1.cs. But when I try to read or write to file I am getting this error:

3条回答
  •  星月不相逢
    2021-01-19 13:01

    I know this question is rather old now but I had come across the same issue and found that the fix was to get the current directory with this line:

    Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.FullName;

    The second Parent gets rid of the reference to the bin. You can then add the path to the file you've added in the same location and it shouldn't take you to bin/debug.

提交回复
热议问题