Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

What is the most reliable way to find the path to the config file for my app?

Posted on 2007-08-03
8
Medium Priority
?
152 Views
Last Modified: 2013-11-05
Visual Studio 2005
VB.NET

I need help understanding the app.exe.config file.  Not so much with using it in code but understanding where it is stored.

For troubleshooting purposes I have added some buttons to my project that FTP various files from our app to our server.  One of the files that I would like to be able to FTP is the config file.  From what I can see it ends up buried in:

  C:\Documents and Settings\Username\Local Settings\Application Data\. . .

while there is also a file with the same name in the app's folder.

Here are my questions.

1)   I want the settings to be valid for all users, not just the user that installs the app or makes configuration changes. How is this done?

2)  What is the easiest way to get the path to the config file so I can FTP it?

3)  Why is there an app.exe.config in my app's folder and one in the Local Settings folder?  The one in the app's folder is never changed and the actual configuration data seems to be stored in the other one.

Thanks,

Todd
0
Comment
Question by:Todd_Anderson
  • 4
  • 2
7 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 19634156
1) Application settings should be stored in the same location as the executable

2) User settings are stored in an isolated storage location under 'Documents and Settings'.

Bob
0
 

Author Comment

by:Todd_Anderson
ID: 19634297
Bob,

I did a lot of reading last night and learned a lot more about my problem.  And its bigger than I thought before.  I don't want a separate set of user settings for each user.  I want one set.  In our situation there are multiple users that log on to the machines that this app will go on but they all need to use the same set of user settings (I know my wording is getting a little confusing but I think you know what I mean).  Setting the scope to application doesn't work because these items get changed from the UI so I have to be able to update them at runtime.

So, at this point I am looking at my options.  The first one that comes to mind is to setup and manage my own config file (xml of course).  The next is to look into manually managing the VS generated app.exe.config file.

Am I going down the right path?  Its hard to beleive that MS didn't build some type of system for global user settings so I'm guessing there might be something that I don't know about.

Todd
0
 

Author Comment

by:Todd_Anderson
ID: 19634310
Bob,

I just found this.  Looks like it might be a solution to my problem.

    http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_21688266.html

Todd
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 96

Expert Comment

by:Bob Learned
ID: 19634855
Todd,

What part of that question is what you are looking for?

Bob
0
 

Author Comment

by:Todd_Anderson
ID: 19634982
Bob,

What I did was take the idea from the other post of creating my own section in the app.exe.config file.  Then I am saving my user configurable settings in that section rather than using the My.Settings functionality that is built in.  This solves my original questions 1 and 2.  The settings are always saved in the config file that is saved at the same path as the app.  Now I know where the file is and there is only one file used for all users.  I've resolved my question 3 while reading about all of this.

I'm using

        Public Config As Configuration = ConfigurationManager.OpenExeConfiguration(Application.ExecutablePath)

With this to load data

    Me.TextBoxOfMine.Text = Config.AppSettings.Settings("SavedValueOfSomeSort").Value

and this to save data.

    Config.AppSettings.Settings("SavedValueOfSomeSort").Value = Me.TextBoxOfMine.Text
    Config.Save()

Here is a sample of my config file.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key="SavedValueOfSomeSort" value="Some value" />
  </appSettings>
</configuration>

It seems to be working but I am still testing some of the details.  I guess what I would like at this point is to know that I am not going way off track here.  It seems pretty straight forward but that's never stopped me in the past.

Todd

   
0
 

Author Comment

by:Todd_Anderson
ID: 19643264
Bob,

Thanks for your comments.  I have resolved this issue as described in my previous post so I will request that this question be deleted.

Todd
0
 
LVL 1

Accepted Solution

by:
Vee_Mod earned 0 total points
ID: 19678682
Closed, 250 points refunded.
Vee_Mod
Community Support Moderator
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Integration Management Part 2
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question