Where are the application settings ?

Lee Taylor 11 Reputation points
2022-05-26T20:14:55.79+00:00

I have developed a new Winforms Application n .Net Core 6 in C#. I used the application settings to create an application setting for my database connection string. Once deployed the user would edit this information to point to their database. However I cannot find where the settings file was deployed (I did a folder deployment). Where can I find this file to edit it once I have installed my app on a different machine?

.NET Runtime
.NET Runtime
.NET: Microsoft Technologies based on the .NET software framework.Runtime: An environment required to run apps that aren't compiled to machine language.
1,125 questions
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. Michael Taylor 48,581 Reputation points
    2022-05-26T21:42:58.143+00:00

    For .NET Core+ apps the settings file is called appsettings.json. It will be sitting in the same directory as the executable. If you don't have an appsettings.json in your project then create one and add the dummy connection string. Within the JSON file is the ConnectionStrings element where the connection string resides. Note however that this should be read only to the end user after installation so unless you update it during installation then it is not where you'd want to store settings changeable for the user.

    .NET Core doesn't actually have any infrastructure in place for storing per-user data like .NET Framwork did. The general recommendation is to use a standard persistent storage like a custom data file in the user's document directory, perhaps the registry if you're desperate or even a database if the data is large.