Home > Software design >  Why my .exe file doesn't work when I install the program?
Why my .exe file doesn't work when I install the program?

Time:09-17

I have a problem when I install my Windows Forms App in a computer. The .exe file doesn't do anything when I click it. To start the aplication, I have to run the program as administrator. It is developed in C#, .Net Framework 4.7.2 and I install it in a computer with Windows 10. THanks!

CodePudding user response:

You should not save anything to the application folder i program files. You should use a separate folder for any data that might change. There are a few locations to chose from:

  • ProgramData contains application data that is not user specific.This data will be available to all users on the computer. Any global data should be put in here.
  • AppData folder contains configuration settings, downloaded information/files for a particular user. So, for example any user specific preferences and profile configurations can be stored in the AppData folder. The AppData folder is further divided into three subfolders
    • Roaming - This folder contains data that can move with your user profile from a computer to another.
    • Local - This folder contains data that will not move with your user profile.
    • LocalLow - You can put in lowlevel access information such as information related to web browser running in a protected mode in this folder.

source

The location for these folders can be accessed by using Special Folders

string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
  • Related