using a config file

  • Thread starter Thread starter Dave Cullen
  • Start date Start date
D

Dave Cullen

I'm a C# noob trying to maintain and modify someone else's code.

The previous programmer used a config file to load parameters for a
database connect string. The file is named app.config and it's in the
project and under VSS source control. I'd like to rename the file to
something more appropriate.

I can't find any reference to that filename in the project, and I don't
know when or how the data gets loaded. I'd like someone to illuminate
that for me please.

I'd also like to know how to rename the file and still have it work.

Thanks.
 
Hi,

I think you better check the docs for the configurations settings in .NET

an app.config is the name of the config file managed by the framework, You
add it in VS and it's included in the project files.

The reason you do not see it being used nowhere is cause the framework is
the one reading and parsing it, when you use
System.Configuration.ConfigurationSettings.AppSettings["Interval"] you are
using that file


cheers,
 
Dave Cullen said:
I'm a C# noob trying to maintain and modify someone else's code.

The previous programmer used a config file to load parameters for a
database connect string. The file is named app.config and it's in the
project and under VSS source control. I'd like to rename the file to
something more appropriate.

You don't want to rename that file. app.config is a special name that
Visual Studio looks for. When you build, Visual Studio will copy app.config
to the build output dirtectory and rename it to YourAppName.exe.config.
I can't find any reference to that filename in the project, and I don't
know when or how the data gets loaded. I'd like someone to illuminate
that for me please.

I'd also like to know how to rename the file and still have it work.

If you rename it, it won't work.
 
Yeah, I found that out after I built the project. There is now a config
file named the same as my exe. Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top