Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

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:

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

Why its trying to search it in bin\Debug? Where I need to put this file so that it can be read/write easily later also I need to create installer for this, will the reference path distub again?

like image 944
coure2011 Avatar asked Dec 16 '22 23:12

coure2011


1 Answers

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".

like image 94
Jon Skeet Avatar answered Dec 24 '22 02:12

Jon Skeet