Problem with My.Computer.FileSystem.CurrentDirectory during Form Load

totty3478

New member
Joined
Sep 13, 2006
Messages
3
Location
Glasgow, Scotland
Programming Experience
Beginner
Hi,

i use a variable in my VB.NET program that holds the location of the Program's install folder, this variable is defined by the

My.Computer.FileSystem.CurrentDirectory

function. However, my pc is on a domain and has a Home folder mapped to the H: drive, when the user logs on windows runs programs from the Home drive, this is standard for windows domain pc's. The problem is that

My.Computer.FileSystem.CurrentDirectory

then becomes H:\ and my Program folder variable points this location. My program has a dependancy on files that are stored in the program's install folder and during logon these files are not found.

the program starts due to a registry entry at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
and this string value does hold the true location of the progam executable.

I have used an IF statement to compare
My.Computer.FileSystem.CurrentDirectory with the value from the run section of the registry and if they are different then use the registry value and not
My.Computer.FileSystem.CurrentDirectory, but the probglem remains, during logon
My.Computer.FileSystem.CurrentDirectory is always H:\

Has anyone seen this problem before and can you help. Thanks

 
Your problem is that My.Computer.FileSystem.CurrentDirectory is NOT your application's folder. It is the current process's current working folder. They may be the same or they may not. Also the current working folder can be changed many times by many things. The folder from which your application was run is Application.StartupPath and the full path of your app's executable is Application.ExecutablePath. These will always be the same if the app is run from the same folder and they will never change of the lifetime of a process.
 
Back
Top