Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Place Visual Studio resource files in a folder other than 'Resources'?

I have a resource file named rs.resx. In the Visual Studio designer, I can add an image to my resource file by clicking "Add resource" and specifying the path to my image file.

After adding the image, the image file itself is also copied to a folder in my Visual Studio solution named Resources. I would like all of my image files to be placed in a folder named Images instead. Is this possible?

like image 915
Dzmitry Avatar asked Feb 01 '11 09:02

Dzmitry


1 Answers

This is a little tricky, but it is possible.

VS checks if the file added to a resource is already defined somewhere within your project. If it can't find it, it creates the folder Resources, puts a copy to the file there, adds this file to the project and puts a reference into the resource designer to this fresh copy of your file.

To avoid this behaviour you should add the file to your project before you add it into the resource file. If the file isn't somewhere within your project structure you can just create a folder, right click it, select Add file and before you click on the Add button of the OpenFileDialog, push on the little arrow next to the button and select Add as link.

Now the file resides on the place on your hdd wherever you like and the resource designer doesn't create a copy within your project file if you now add the file within the resource designer.

Maybe this little picture helps to find the Add as link button: Add as link
(source: modbusdriver.com)

like image 85
Oliver Avatar answered Nov 15 '22 06:11

Oliver