Results 1 to 4 of 4

Thread: Limit Browse Folder Root?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 1999
    Posts
    106
    I have researched the various API calls, common dialog options, etc. but still can't find a decent answer.

    Is it possible, using ANY of these methods, to display to the user only folders beneath a certain directory?
    That is, assume the default path is C:\mail\2000.
    I want to force the user to select only subdirectories (folders) beneath this (which include Jan_Mail, Feb_Mail, etc.).

    When the user first sees the "Browse for Directory" box, it should display ONLY the 2000 folder. Then, the user has to select one folder such as Jan_Mail, Feb_Mail, March_Mail, etc. Can this be done, or must you always start from a predefined root (Desktop, C:\Windows, etc.)???

    THANKS for any insight and advice.
    Steve


  2. #2
    Addicted Member
    Join Date
    Aug 1999
    Location
    Ottawa,ON,Canada
    Posts
    217
    Design your custom form using the TreeView control, design it so that the top-level Node is for the root directory that you want it to be, it takes some coding but I believe this will give you what you want.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Oct 1999
    Posts
    106

    Talking TreeView Rocks!

    Thanks a lot SonGouki, that is exactly what I needed!

    As a side note, do you know a quick method that returns just the subdirectory/folder selected from TreeView?

    Example: Mailouts.SelectedFolder = C:\mail2000\mail0428
    How do I move just the last folder selected (mail0428) into a variable using string manipulation?

    Thanks Again!
    Steve

  4. #4
    Addicted Member
    Join Date
    Aug 1999
    Location
    Ottawa,ON,Canada
    Posts
    217
    You can use the InStrRev function as follows:
    Code:
       Dim iSeparatorPos As Integer
       Dim sFullPath As String
       Dim sSubDir As String
       
       sFullPath = Mailouts.SelectedFolder
       
       If Right(sFullPath, 1) = "\" Then
          sFullPath = Mid(sFullPath, 1, Len(sFullPath) - 1)
       End If
       
       iSeparatorPos = InStrRev(sFullPath, "\")
       
       If iSeparatorPos > 0 Then
          sSubDir = Mid(sFullPath, iSeparatorPos + 1)
       Else
          sSubDir = sFullPath
       End If
       
       Call MsgBox(sSubDir)
    Hope this is what you were looking for.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width