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

后端 未结 3 495
走了就别回头了
走了就别回头了 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:14

    Presumably it's because you're running in bin\Debug - that's where the application is being launched.

    One option is to set the build action for the file to "Content" so that it will copy it into the output directory along with your executable. EDIT: As Hans as pointed out, you should also set the "Copy to Output Directory" property to "Copy Always" or "Copy if newer".

提交回复
热议问题