views:

42

answers:

1

When a user click the .msi, i want a folder called "Your Files", which comes with two small images by default, to be created in C:\Users\YourName\Documents. In short, MyDocuments.

What i did is put the following code in program.cs:

string myDocuments = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
string downloadArea = System.IO.Path.Combine(myDocuments, "Your Files");
System.IO.Directory.CreateDirectory(downloadArea);

Just before:

Application.Run(new mainForm());

The problem is, this folder will be created every time the user runs the application which is not a good solution, also in this case there is no place to load the two images so it can be loaded while the folder is created. I want the folder to be created once preferably while installing the application, so even when i uninstall the folder "Your Files" and its sub files be deleted automatically along with the program files. I tried to do it via Setup Project, but i couldn't.

Any help will be appreciated.

+1  A: 

You need to create folder in your Setup project. Perform the following steps:

Right click on your setup project -> View -> File System

Right click on node “File system on target machine” -> Add special folder -> User’s personal data folder

Right click on node “User’s personal data folder” -> Add -> Folder -> type “Your Files”

Now you can add to this folder files you need in your setup project. After deployment they will be in users “My documents”

Maxsur
Awesome.........
There is a problem, i have two seperate applications. First application deployed ok as needed. The second one doesn't produce the the folder in MyDocuments. In the second application i followed the exact same steps of the first application deployment steps, i just changed the folder names to avoid any clashes. The first app deployed ok and create files fine. The second doesn't create the folder under Documents. I need help, any idea?
It's a very strange situation.Please, double check all your setup project settings once again.Look into Event Viewer System and Application logs to see any errors during and after deployment.Try to change Folder Names once again - may be you misspelled something...
Maxsur