user1415780
user1415780

Reputation: 1153

initiating a string from a config file

I am asked to do this and I have no clue from where to start since I am new to it.

I have created a C# .NET application (a web api to be more precise) using Visual Studio 2012.

I created an lsi file ( the new version of msi files) to be able to deploy it on a server.

Now I want to create some sort of a configuration file where I can edit a string without having to go into the code every time to change it every time.

lets say the variable is called mystring: 1- how can I create a config file that request a string without having to go into the code? 2- how can I say the mystring=input string ?

I tried to look it up but since I don t have the exact name I don t really know what I am searching for ...

Thanks,

Upvotes: 2

Views: 63

Answers (1)

Amicable
Amicable

Reputation: 3101

One solution would be to save a configuration file with the settings you want to load, I'd suggest saving it to the ProgramData folder.

I would save the settings to an XML file (or JSON) so you can serialize and deserialize the data into your program when it loads. Guide

You can also save other details so they'll persist each time the application is opened this way, such as a username field.

Upvotes: 1

Related Questions