

Professional custom Windows software development services from IQ Direct Inc., USA. So, for storing the settings it is better to use dedicated folders. So if the user runs the program twice, one time using the administrator account, and the second time using the user account, they may get two separate settings files, which may lead to confusion. For user accounts, the settings files are automatically redirected to the respective folder inside AppData folder. Please be careful when storing the settings in the Program Files folder, This folder is protected by Windows security policy for non-administrative accounts. String strSettingsXmlFilePath = System.IO.Path.Combine(strWorkPath, "Settings.xml") C:\Program Files\MyApplication\Settings.xml Here I am giving a console application example to open directory with the help of Process.Start() method. Using the Process component we can obtain the list of the running processes in the system and we can also start the new process in the system. You can use it later to access your settings or asset files: Process component provides to access the process, which is running in the system. The variable strWorkPath will contain just the current path of executable residing in. String strWorkPath = System.IO.Path.GetDirectoryName(strExeFilePath) This will strip just the working path name: C:\Program Files\MyApplication\MyApplication.exe This will give us the full name path of the executable file: NET Console Applications and for C# Windows Forms Applications: But we have found the one that is working both for C#. There are several options to find the current executable path in C#. The working folder is needed to access settings, database, images, or resource files residing in the same directory as the currently running C# executable file of your program. Sometimes you may want to get the current executable file path of your C# program.
