What's the appropriate folder for an application's configuration files

mjeschke 40 Reputation points
2025-09-19T20:36:47.22+00:00

I'm developing a C# Windows Form application in Visual Studio 2022 but probably besides the point. The tag dropdown confuses me. I digress...

Is there a more appropriate location to store application configuration information then under "program files" folder? Ideally I kind of like it in the program files folder but don't want to mess with "administrator privilege's" to run the program.

BACKSTORY: My application has an XML file it references containing settings. These settings are editable through a form that is launched via menu strip on the main application. Application runs perfectly if I launch it with administrator privilege's. Otherwise it crashes upon opening that form referencing the file. Pretty sure because I'm storing those configuration files in the applications root folder under "program files".

Developer technologies | Windows Forms
{count} votes

3 answers

Sort by: Most helpful
  1. Castorix31 91,191 Reputation points
    2025-09-20T06:49:59.0333333+00:00
    0 comments No comments

  2. KOZ6.0 6,735 Reputation points
    2025-09-23T00:19:00.5833333+00:00

    You can use ApplicationData or CommonApplicationData.

    // C:\Users\<UserName>\AppData\Roaming
    var userData = System.Environment.GetFolderPath(
                 System.Environment.SpecialFolder.ApplicationData);
    
    // C:\ProgramData
    var commonData = System.Environment.GetFolderPath(
                 System.Environment.SpecialFolder.CommonApplicationData);
    

  3. ALI AMIN 0 Reputation points
    2025-09-24T17:57:38.0933333+00:00

    This discussion about configuration file storage is really useful — especially the point about avoiding Program Files and instead using ApplicationData or CommonApplicationData. In a similar way, users in Pakistan benefit from digital tools that make daily tasks easier, like platforms where they can check electricity bills online without hassle. Thanks for sharing these best practices!

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.