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. open file directory

open file directory

Scheduled Pinned Locked Moved Visual Basic
question
13 Posts 5 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.
  • I iamalik

    You can use FolderBrowserDialog for this purpose

    C Offline
    C Offline
    captainmogo
    wrote on last edited by
    #3

    Thanks for the reply, I looked at the folderbrowserdialog as you suggested and it seems as if it does the same thing. I cannot do anything else on the main form until i select a folder or press cancel. That is not exactly what I was going for. Instead of putting a shortcut on the desktop the the application log file, I wanted to open the folder from a button on the front panel. If the folder stays open in the background, the application doesnt care. Is this not possible.

    I 1 Reply Last reply
    0
    • C captainmogo

      Thanks for the reply, I looked at the folderbrowserdialog as you suggested and it seems as if it does the same thing. I cannot do anything else on the main form until i select a folder or press cancel. That is not exactly what I was going for. Instead of putting a shortcut on the desktop the the application log file, I wanted to open the folder from a button on the front panel. If the folder stays open in the background, the application doesnt care. Is this not possible.

      I Offline
      I Offline
      iamalik
      wrote on last edited by
      #4

      I guess you want to the browse to the some path when LogFiles button is clicked. You need to set SelectedPath property FolderBrowserDialog in button click event. Isn't it

      C 1 Reply Last reply
      0
      • I iamalik

        I guess you want to the browse to the some path when LogFiles button is clicked. You need to set SelectedPath property FolderBrowserDialog in button click event. Isn't it

        C Offline
        C Offline
        captainmogo
        wrote on last edited by
        #5

        yeah thats what I want but I was hoping it could display in the background. Both the folderbrowse and openfile dialog open as modal, it seems, preventing me from doing anything else on the form. I was hoping maybe the folder could open and just sit in background in case the user needed to open one of the files at a later time. I thought there might be a way to do it that didnt require opening an actual file/folder from within the code. Is that not typical?

        I 1 Reply Last reply
        0
        • C captainmogo

          This is probably a newbie question and I am just not getting it today but... I just want to open a file directory so that the user can open a text file but I dont need to use it in the program. The main form has a button called 'LogFiles' and when the user presses it, I just want it to open the directory and do nothing else. I was using OpenFileDialog but that is stopping execution until a file is chosen. Am i missing something obvious. Thanks

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #6

          Hi, I see three ways of getting a look at a directory: 1. use an existing folderbrowser dialog; since it is a dialog, it will have modal behavior. 2. open up the folder using Windows Explorer; use Process.Start(fileName) to make it happen. This launches a separate process and will behave completely independently of your app. 3. write your own Form that somehow displays folder contents, and Show() it modelessly. :)

          Luc Pattyn [Forum Guidelines] [My Articles]


          - before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets


          C 1 Reply Last reply
          0
          • C captainmogo

            yeah thats what I want but I was hoping it could display in the background. Both the folderbrowse and openfile dialog open as modal, it seems, preventing me from doing anything else on the form. I was hoping maybe the folder could open and just sit in background in case the user needed to open one of the files at a later time. I thought there might be a way to do it that didnt require opening an actual file/folder from within the code. Is that not typical?

            I Offline
            I Offline
            iamalik
            wrote on last edited by
            #7

            I am cofused with Background. If you dont want to show to dialog box than you need to save your log file path in some variable. Nothing else

            T 1 Reply Last reply
            0
            • L Luc Pattyn

              Hi, I see three ways of getting a look at a directory: 1. use an existing folderbrowser dialog; since it is a dialog, it will have modal behavior. 2. open up the folder using Windows Explorer; use Process.Start(fileName) to make it happen. This launches a separate process and will behave completely independently of your app. 3. write your own Form that somehow displays folder contents, and Show() it modelessly. :)

              Luc Pattyn [Forum Guidelines] [My Articles]


              - before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets


              C Offline
              C Offline
              captainmogo
              wrote on last edited by
              #8

              Thanks Luc, by background, what I really meant was, independent of my application. I wanted an explorer window to stay open regardless of whether or not a file was chosen. I just couldnt explain myself properly. Process.Start was just what I was looking for!

              1 Reply Last reply
              0
              • C captainmogo

                This is probably a newbie question and I am just not getting it today but... I just want to open a file directory so that the user can open a text file but I dont need to use it in the program. The main form has a button called 'LogFiles' and when the user presses it, I just want it to open the directory and do nothing else. I was using OpenFileDialog but that is stopping execution until a file is chosen. Am i missing something obvious. Thanks

                A Offline
                A Offline
                Alan N
                wrote on last edited by
                #9

                Hi, I think that you want to open a Windows Explorer window at a particular directory for the convenience of your users, correct? In which case use System.Diagnostics.Process.Start(pathname) [EDITED typo] The Start method has many overloads and this simple one uses the associated application to open pathname. So as an example, if pathname is d:\logfile.txt then Notepad is used to open the file d:\logfile.txt. What you might not have realised is that directories are associated with Explorer. As a consequence if pathname is a directory, e.g. d:\logfiles then the Start method will open an Explorer windows at the d:\logfiles directory. Alan. [EDIT: Like Luc said a few minutes ago]

                modified on Wednesday, March 18, 2009 4:09 PM

                C 1 Reply Last reply
                0
                • A Alan N

                  Hi, I think that you want to open a Windows Explorer window at a particular directory for the convenience of your users, correct? In which case use System.Diagnostics.Process.Start(pathname) [EDITED typo] The Start method has many overloads and this simple one uses the associated application to open pathname. So as an example, if pathname is d:\logfile.txt then Notepad is used to open the file d:\logfile.txt. What you might not have realised is that directories are associated with Explorer. As a consequence if pathname is a directory, e.g. d:\logfiles then the Start method will open an Explorer windows at the d:\logfiles directory. Alan. [EDIT: Like Luc said a few minutes ago]

                  modified on Wednesday, March 18, 2009 4:09 PM

                  C Offline
                  C Offline
                  captainmogo
                  wrote on last edited by
                  #10

                  Hi, I dont think i understand correctly. 1. Yes, I do want to open an explorer window, not a file as your example demonstrates 2. I cannot find System.Diagnostics.Start

                  A 1 Reply Last reply
                  0
                  • C captainmogo

                    Hi, I dont think i understand correctly. 1. Yes, I do want to open an explorer window, not a file as your example demonstrates 2. I cannot find System.Diagnostics.Start

                    A Offline
                    A Offline
                    Alan N
                    wrote on last edited by
                    #11

                    Ah, my mistake. If I had written System.Diagnostics.Process.Start, the original post might have made more sense. In the System.Diagnostics namespace is the Process class and that has a Start method. If you pass a directory path to the Start method it will open an Explorer window at that path. Alan.

                    modified on Wednesday, March 18, 2009 3:59 PM

                    C 1 Reply Last reply
                    0
                    • I iamalik

                      I am cofused with Background. If you dont want to show to dialog box than you need to save your log file path in some variable. Nothing else

                      T Offline
                      T Offline
                      tech603
                      wrote on last edited by
                      #12

                      What you want to do is utilize the background worker process. This will allow you to open the dialog in its own thread not affecting the main form. I have done this for an application for saving or zipping files. I found that if i did not use the background worker process my form would lock up until the save/zip was completed. I found this article very helpful. http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx[^] Hope that helps. Matthew Vass QA Analyst mvass@hostmysite.com http://www.hostmysite.com?utm_source=bb[^]

                      1 Reply Last reply
                      0
                      • A Alan N

                        Ah, my mistake. If I had written System.Diagnostics.Process.Start, the original post might have made more sense. In the System.Diagnostics namespace is the Process class and that has a Start method. If you pass a directory path to the Start method it will open an Explorer window at that path. Alan.

                        modified on Wednesday, March 18, 2009 3:59 PM

                        C Offline
                        C Offline
                        captainmogo
                        wrote on last edited by
                        #13

                        ah Got it now... Thanks again for everyone's help

                        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