Click here to Skip to main content
15,888,065 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello all,

I want to install my program on another computer. My aim is saving an image to a file for using later. But the image isn't being saved.

C#
image.Save(Application.StartupPath + "\\" + "data" + "\\" + "config" + "\\" + "Choosen.bmp");


(Application.StartupPath = C:\Program Files (x86)\PT\My Product Name)

There has to be an image in the directory after that line. It works when i execute the code from the solution, but it doesn't work when i set the program up on another computer. I prepared te setup project with InstallShield. I checked the directory (C:\Program Files (x86)\PT\My Product Name\data\config) , and it exists. I added all dll files which i used in solution project to setup project. Waiting for your helps.

Thanks
Posted

1 solution

No, the image won't save.
When you install an application in production, it is installed in a folder below the "Program Files" or "Program Files (x86)" folded - and by default these folders are all write protected to help reduce the impact of Trojans, viruses, and so forth.

So when you try to write to it, you get an access violation and the file isn't written there.

While it is possible to get round this, it really isn't recommended - and there is no guarantee that it won't get even more restrictive in future releases of the OS) so the best thing to do is to change where you store data: Where should I store my data?[^] should help.
 
Share this answer
 
Comments
Çağrı Daşkın 13-Mar-15 5:55am    
Thank you very much.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900