Solved

How to retrieve application settings when program installed to a new location

Posted on 2015-02-24
2
95 Views
Last Modified: 2015-03-13
I have a VB.Net program, called (for instance) "MyProgram", that was installed to a folder in Program Files called, "MyProgram v. 1".  This program has application settings that Windows stores in a folder called "MyProgram_Url_n4n5qrewg1zi5ilbibrsl21idmzcsdhw", which is located in the "AppData\Local" folder.  In the program there is the following code:

If My.Settings.CallUpgrade Then
     My.Settings.Upgrade()
     My.Settings.CallUpgrade = False
     My.Settings.Save()
End If

This code ensures that when I update my program, say from v. 1.0.0.0 to v. 1.1.0.0, that the application settings from the previous version.  This has worked very well and I have upgraded my application numerous times without a problem.  And each new version adds a new folder to the application data folder with the version number as the folder name containing a "user.config" file.

However, I now want to do a major upgrade to v. 2.0, and want to change the location of installation of the program (in Program Files) from "MyProgram v. 1" to simply, "MyProgram", since it is silly to keep the version number in the folder name.  However, when the program is installed, there are now two folders in Program Files:  "MyProgram v. 1" and "MyProgram", and there is now a new folder in the "AppData\Local" folder, "MyProgram_Url_w1x02urygryc3nq3z4ajs5h3r3rc443k", which only contains a folder named "2.0.0.0".  It does not have folders for the older versions, because those version folders are contained in the application data folder created for verison 1.0.0.0 of the program.

So it appears that once I change the installation location of the program, Windows treats it as a new application and creates a new place to store the application data.  My question is if there is any way to change this and/or have version 2.0 of "MyProgram" be able to find the previous version's config file to use as a base for its settings?  Thank you.

Vijay
0
Comment
Question by:vdurbal
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 500 total points
ID: 40629751
Normally, it's not the installation directory that is recorded in AppData\Local, it's the application name.

Have you also changed the application name in the Project's properties?

This being said, if you look into the AppData\Local directories, you will see that the only thing in there is a file called user.config. If you examine the content of the file, you will see that it makes no reference to the program name or it's location. So simply copying the user.config from the old installation to the new one should do the trick.
0
 

Author Closing Comment

by:vdurbal
ID: 40663402
Thank you very much.  That worked!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
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…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses

617 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