here is the question: when you have a file you can open properties of that file and set "Copy to Output Directory" to "Always Copy",however, when you want to do the same thing for a folder, there is no option for copying.
all there is rest to create that folder is to create it programmatically.
do you know how to do that the way you do it for a file?

copy to output directory just makes a copy of the selected resource where the program is compiled to. It has no real significance other than keeping you from having to manual find and copy files to a single location.

if you need a sub directory in the same directory as your application. you are best off checking if it exists, and if not, creating it programmatically. Its simple and effective.

that is exactly what i said above.

If you just want to copy an empty folder, it won't work, but if the folder contains files, you can right click in the soution and click create new folder, then copy your files in explorer to that new folder in your project directory, then go back to your solution and right click on the folder and click add existing, then select the files that are already in that folder, this will add them to your solution under that folder, expand it and select them, you get the copy to output option then, and if you choose to always copy, then it will create the subdirectory and fill it with the files.

yeah i got it but, i want to be able to create a folder without putting anything inside, like an asp.net web application, you create a folder in your application, even if it is empty it is created on the target folder.

you could create a dummy file, a little text file or something that serves no purpose but to encourage the creation of the folder, but other than that, you might just have to wait for a new version of VS to fix that.

you could create a dummy file, a little text file or something that serves no purpose but to encourage the creation of the folder, but other than that, you might just have to wait for a new version of VS to fix that.

This is the method I use and that I see a lot of third party vendors use. Just create an empty file called "dirinfo", or any other name, so the installer will create the directory.

You're also choosing the right way to go as far as having the installer create the directory because when an .msi is installed it maintains a manifest of the files it created on the file system so when the package is uninstalled it will remove that directory if it is empty. So if you create the placeholder and they never use the output directory it will be cleaned up when uninstalling. If they have files in the output directory it will leave the output files but remove everything else from the installer.

i think the best way is to create the folder programmatically using Directory.Exist() method, making directory name property is good, when you try to get the name it will check the folder, if it does not exist, it will create and return you the name. if it exists it is going to return you the name without creating anything.

But doing so in code outside of the MSI means that the directory will not be cleaned up when the application is uninstalled.

commented: good catch +4

But doing so in code outside of the MSI means that the directory will not be cleaned up when the application is uninstalled.

very good catch, then you need to add custom action dll(custom installer class) to your setup project and and override on after uninstall event and you should manually delete that folder.

commented: i never thought of that and its simple enough +2
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.