user311509
user311509

Reputation: 2866

I Need Help Deploying a Winform Application Using Setup Project

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.

Upvotes: 2

Views: 1313

Answers (1)

Maxsur
Maxsur

Reputation: 46

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”

Upvotes: 2

Related Questions