Selecting a directory with the Common Dialog

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Djeek
    New Member
    • Feb 2008
    • 8

    Selecting a directory with the Common Dialog

    I tried to use the Common Dialog for choosing directories like many programs do but I did not manage it. You always have to select a file but I don't want to see/select files, only directories!
    Earlier posts on this issue were not (proper) answered.
    I searched the MSDN Library, Internet and this forum but found no answers...
    Please...
  • jamesd0142
    Contributor
    • Sep 2007
    • 471

    #2
    What version of vb are you using?

    There is a:
    "FolderBrowserD ialog"
    in vb 2005

    which would solve you problem

    Comment

    • debasisdas
      Recognized Expert Expert
      • Dec 2006
      • 8119

      #3
      You can still use the VB 6.0

      Try to find the location of the file using the CD control.

      Try to remove file name part and you will get the directory.

      Comment

      • Djeek
        New Member
        • Feb 2008
        • 8

        #4
        Originally posted by Djeek
        I tried to use the Common Dialog for choosing directories like many programs do but I did not manage it. You always have to select a file but I don't want to see/select files, only directories!
        Earlier posts on this issue were not (proper) answered.
        I searched the MSDN Library, Internet and this forum but found no answers...
        Please...
        Both thanks for reply.
        Stripping the file from the path is no problem but I don't want to navigate files debasisdas.
        That "FolderBrowserD ialog" sounds interesting jamesd0142! I don't know it. Is it a custom control? Does it still exist in VB6? MSDN Library does not know it.
        How can I invoke it? I'm using VB6 6.0.8169.
        grts

        Comment

        • jamesd0142
          Contributor
          • Sep 2007
          • 471

          #5
          Originally posted by Djeek
          Both thanks for reply.
          Stripping the file from the path is no problem but I don't want to navigate files debasisdas.
          That "FolderBrowserD ialog" sounds interesting jamesd0142! I don't know it. Is it a custom control? Does it still exist in VB6? MSDN Library does not know it.
          How can I invoke it? I'm using VB6 6.0.8169.
          grts
          I never used VB6 although I do know VB 2005 is a later version, much closer to VB.NET.

          Im sure Killer42 would have an answer to your latest question however.

          James

          Comment

          • Djeek
            New Member
            • Feb 2008
            • 8

            #6
            Its disappointing not finding answers here... but all who repied: THANKS!

            Comment

            • debasisdas
              Recognized Expert Expert
              • Dec 2006
              • 8119

              #7
              Have you tried working on as suggested in Post #3

              Comment

              • Djeek
                New Member
                • Feb 2008
                • 8

                #8
                I dont know if I have a CD control. I can not find such control in my VB6 installation. It isnt the multimedia control I suppose.
                But... I (the user) dont want to have to choose a FILE at first and stripping it from the path. I even dont want show the files in the directories! Stripping the path is also possible with the standard Common Dialog!
                Many programs offer the possibility to choose a DIRECTORY. Thats all, but HOW?

                Comment

                • debasisdas
                  Recognized Expert Expert
                  • Dec 2006
                  • 8119

                  #9
                  Have you tried using Drive Listbox and directory listbox.

                  Comment

                  • QVeen72
                    Recognized Expert Top Contributor
                    • Oct 2006
                    • 1445

                    #10
                    Hi,

                    This code will allow you to select the Directory..

                    [code=vb]
                    With cdlg
                    .Flags = cdlOFNPathMustE xist
                    .Flags = .Flags Or cdlOFNHideReadO nly
                    .Flags = .Flags Or cdlOFNNoChangeD ir
                    .Flags = .Flags Or cdlOFNExplorer
                    .Flags = .Flags Or cdlOFNNoValidat e
                    .FileName = "*.txyz" 'Dummy File
                    .CancelError = True
                    '
                    On Error Resume Next
                    .Action = 1
                    If Err = 0 Then
                    MsgBox Left(.FileName, Len(.FileName) - 7)
                    End If
                    End With
                    [/code]

                    This flag : cdlOFNNoValidat e allows you to get the Browsed Path, even if no File is Selected

                    Regards
                    Veena

                    Comment

                    • Djeek
                      New Member
                      • Feb 2008
                      • 8

                      #11
                      I tried your common dialog settings Veena and it worked. Unfortunately is the dummy file not so nice.
                      At the end ;=) I followed your proposal to use the Drive and the Directory Listbox debasisdas!
                      My preference was the generic Windows Common Dialog...
                      All thanks for your help!

                      Comment

                      Working...