Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS solution folder not generating in the bin/debug or release folder

I have added a solution folder on my visual solution project. I have added some text files inside that folder.

I have Built and Rebuilt my solution but still nothing.

The error I get when trying to access a file from the folder:

System.IO.StreamReader file0 = new System.IO.StreamReader(Path.Combine(Environment.CurrentDirectory, @"newFolder\SampleText.txt"));

An unhandled exception of type 'System.IO.DirectoryNotFoundException' occurred in mscorlib.dll

Additional information: Could not find a part of the path 'I:\Programming\Projects\SampleProject\SampleProject\SampleProject\bin\Release\newFolder\SampleText.txt'.

The path to the Release folder is valid, but newFolder is not inside. I don't understand why it is not being generated, any help would be great.

like image 679
Peter Avatar asked Aug 18 '14 01:08

Peter


People also ask

What is bin Debug folder?

The bin folder holds binary files, which are the actual executable code for your application or library. Each of these folders are further subdivided into Debug and Release folders, which simply correspond to the project's build configurations.

How do I create a release folder in Visual Studio?

The simplest way of doing it is by adding the desired folder to your project and the exe file on the folder. Change the properties of the exe file to "Content" and "Copy always". By doing that, everytime you rebuild your solution, the output will have the folder and exe file.

What is Copytooutputdirectory?

"Copy to Output Directory" is the property of the files within a Visual Studio project, which defines if the file will be copied to the project's built path as it is. Coping the file as it is allows us to use relative path to files within the project.


2 Answers

Click on your text file, change Copy to Output Directory to Copy if newer or Copy always. This will copy the file and any folder structure beneath it up to the project level and re-create it in the output folder.

enter image description here

enter image description here

like image 52
Scott Chamberlain Avatar answered Nov 14 '22 22:11

Scott Chamberlain


The answers correct. You need to change "Copy to Output Directory" to "Copy Always" or "Copy If Newer" BUT YOU NEED TO DO ONE MORE THING. You need to choose Build Action as "Content". By doing so the folders that contain the files are generated in debug folder automatically without hassle. The other Build Actions may also work I am not sure but not "Resource" one.

like image 30
smoothumut Avatar answered Nov 14 '22 23:11

smoothumut