Reset the current directory to AppPath on exit
-
How do I reset the active directory to the directory where I started the program from without using relative or absolute paths? Is it possible? Thanks in advance :) :laugh: edit: The reason I need this is that I use openfiledialogs and savefiledialogs which changes the current directory, and I have stored help files relative to the program path. ---- Dim Sleepy as Boolean = True If Me.Sleepy = True Then Goto Sleep End If ---- -- modified at 8:45 Thursday 16th February, 2006
-
How do I reset the active directory to the directory where I started the program from without using relative or absolute paths? Is it possible? Thanks in advance :) :laugh: edit: The reason I need this is that I use openfiledialogs and savefiledialogs which changes the current directory, and I have stored help files relative to the program path. ---- Dim Sleepy as Boolean = True If Me.Sleepy = True Then Goto Sleep End If ---- -- modified at 8:45 Thursday 16th February, 2006
-
How do I reset the active directory to the directory where I started the program from without using relative or absolute paths? Is it possible? Thanks in advance :) :laugh: edit: The reason I need this is that I use openfiledialogs and savefiledialogs which changes the current directory, and I have stored help files relative to the program path. ---- Dim Sleepy as Boolean = True If Me.Sleepy = True Then Goto Sleep End If ---- -- modified at 8:45 Thursday 16th February, 2006
Set...
myOpenFileDialog.RestoreDirectory = True mySaveFileDialog.RestoreDirectory = True
This will prevent the app's current directory from changing and allow these dialogs to still remember the last selected path.DJLarZ wrote:
The reason I need this is that I use openfiledialogs and savefiledialogs which changes the current directory, and I have stored help files relative to the program path.
It sounds like you are accessing your help files via relative paths. If so, then I strongly recommend that you access them via absolute paths, which can be built based on Application.StartupPath. The reason is if someone makes a shortcut to your app but forgets to set the working directory to the app's path, this will break all of the relative paths to your files.
-
How do I reset the active directory to the directory where I started the program from without using relative or absolute paths? Is it possible? Thanks in advance :) :laugh: edit: The reason I need this is that I use openfiledialogs and savefiledialogs which changes the current directory, and I have stored help files relative to the program path. ---- Dim Sleepy as Boolean = True If Me.Sleepy = True Then Goto Sleep End If ---- -- modified at 8:45 Thursday 16th February, 2006
DJLarZ wrote:
The reason I need this is that I use openfiledialogs and savefiledialogs which changes the current directory, and I have stored help files relative to the program path.
You should not be worrying about what the current directory is. You should be using absolute paths ALWAYS when dealing with files. You can always get the applications directory by using:
Dim appDirectory As String = Application.StartupPath
You can make a fully qualified path name by using something like this:
Imports System.Io
.
.
.
Dim myHelpFilePath As String = Path.Combine(Application.StartupPath, "myHelpFile.hlp")RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-
How do I reset the active directory to the directory where I started the program from without using relative or absolute paths? Is it possible? Thanks in advance :) :laugh: edit: The reason I need this is that I use openfiledialogs and savefiledialogs which changes the current directory, and I have stored help files relative to the program path. ---- Dim Sleepy as Boolean = True If Me.Sleepy = True Then Goto Sleep End If ---- -- modified at 8:45 Thursday 16th February, 2006