Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Reset the current directory to AppPath on exit

Reset the current directory to AppPath on exit

Scheduled Pinned Locked Moved Visual Basic
questionwindows-adminhelp
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    DJLarZ
    wrote on last edited by
    #1

    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

    M J D D 4 Replies Last reply
    0
    • D DJLarZ

      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

      M Offline
      M Offline
      malharone
      wrote on last edited by
      #2

      There is a property on the Dialogbox which you can specify to restore the location to the original value. - Malhar

      1 Reply Last reply
      0
      • D DJLarZ

        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

        J Offline
        J Offline
        Joshua Quick
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • D DJLarZ

          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

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          • D DJLarZ

            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

            D Offline
            D Offline
            DJLarZ
            wrote on last edited by
            #5

            Thank you very much, all of you, it solved my problem. :) ---- Dim Sleepy as Boolean = True If Me.Sleepy = True Then Goto Sleep End If ----

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups