By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,572 Members | 1,439 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,572 IT Pros & Developers. It's quick & easy.

Installation path & Environmental Settings

P: 72
have a program that is almost finalized; but I have a slight problem with my XML file that i'm using. After the program runs, it outputs an XML file but I want this XML file to go a location in the installation folder where the program was installed to.

I also need this file to be readable in this program and other programs. So basically, the file location/name/path can't change and I need to be able to reference when I want to in the code.

But - seeing how this is my first program of this magnitude, i'm clueless. I've read around online about the Environment Settings and that is probably what i'm looking for...but any more clues ?
Dec 3 '12 #1
Share this Question
Share on Google+
6 Replies

Expert Mod 5K+
P: 5,397
First: I have VERY little background in dot-net.

Something you might take a look at is: .net registry entries I normally program MS Access in VBA and I will occasionally store some values in the registry such as file paths or reset tokens, etc...
Dec 3 '12 #2

P: 72
I found another way that will hopefully do the same thing. If any of you are VB gurus, please warn me if this is not the right way.

Expand|Select|Wrap|Line Numbers
  1. XmlWriter.Create(System.Environment.SpecialFolder.ProgramFilesX86 & "\ATR\BackupProgram\Backup.xml", Backxml)
Dec 4 '12 #3

Expert Mod 5K+
P: 5,397
My problem with environment variables is that they can be restricted by IT to the administrator group using GPO; In fact, several of my applications broke when I.T. moved us to WinXP-Pro-Enterprise as they locked down the O.S. However, the default area for VBA to write to is not normally restricted. I suspect that you'll run into the same issues when a user under a restricted account runs your application and it can't write or create the variables.
Dec 4 '12 #4

Expert Mod 100+
P: 465
The only issue I can see with your solution is if someone is installing your application running a 32 bit version of windows there isn't going to be a Program Files (x86) folder like there is on the 64 bit version
Dec 5 '12 #5

P: 72
Well Mr. Coder, it seems i have another issue that my friends believe to be a permission issue.

System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Program Files (x86)\ATR\Save A Job\obj\Release\42\ATR\BackupProgram\Backup.xml'.
For some reason, the program is looking for the backup.xml file in the wrong place. (and seemingly adding folders)

The way i'm calling the backup.xml file in the program is by
Expand|Select|Wrap|Line Numbers
  1. (System.Environment.SpecialFolder.ProgramFile sX86 & "\ATR\Save A Job\Backup.xml") or (Directory.GetCurrentDirectory & "Backup.xml")
which, could be the wrong way, but it makes sense to me. But i would assume that the full path to the file location would be as follows:

"C:\Program Files (x86)\ATR\Save A Job\backup.xml"

however, it is looking for it in the wrong place (obvious from the error)
Dec 5 '12 #6

P: 72
Got it fixed guys. It was the permissions to the installation folder. It was set to "read/write only"...once i switched it to Full Control, everything worked fine
Dec 5 '12 #7

Post your reply

Sign in to post your reply or Sign up for a free account.