CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2000
    Location
    Arizona, USA
    Posts
    493

    Listing Folders In A Network Location

    How Can I list all the folders in a network location without mapping a drive to the
    location? For example we have a server named Delta. How can I list all the folders in the
    location \\Delta\
    I would also like to know the size of each folder.
    Any help is greatly appreciated!!!

    Kris
    Software Engineer
    Phoenix,AZ
    Kris
    Software Engineer
    Phoenix, AZ USA

  2. #2
    Join Date
    Apr 2000
    Location
    South Carolina,USA
    Posts
    2,210

    Re: Listing Folders In A Network Location

    Kris,
    Enumerating folders in a remote computer is similar to a local computer except you need to supply the remote computers name and the Share name of the drive like so

    option Explicit

    private Sub Command1_Click()
    Dim str
    str = Dir("\\LAPTOP\C DRIVE\WINDOWS\*.*", vbNormal)
    Do While str <> "" ' list all the files in windows folder
    Debug.print str
    str = Dir
    Loop
    End Sub



    LAPTOP is the name of a remote computer and C Drive is the share name that was given it when the drive was set as sahared.



    John G

  3. #3
    Join Date
    Mar 2000
    Location
    Arizona, USA
    Posts
    493

    Re: Listing Folders In A Network Location

    Is there a way to list all the share names on the pc. All I look at is the pc name i.e. \\Delta
    All the folders are at that location but are actually shared folders on that server.
    There is no drive name. So a folder named "John" would have a path like \\Delta\John\

    Kris
    Software Engineer
    Phoenix,AZ
    Kris
    Software Engineer
    Phoenix, AZ USA

  4. #4
    Join Date
    Apr 2000
    Location
    South Carolina,USA
    Posts
    2,210

    Re: Listing Folders In A Network Location

    There probably is a way but I don't know how. Maybe someone else can help. I don't have the resources to reproduce that sort of environment.

    John G

  5. #5
    Join Date
    Mar 2000
    Location
    Arizona, USA
    Posts
    493

    Re: Listing Folders In A Network Location

    I will keep looking for how to get the share names. I am using the current method to get all
    the folder names given a path. Do you know how to get the folder sizes? I tried using FileLen
    but since it is a directory it just returns "0" I can do it with the FileScriptingObject but it
    takes a very long time where as the Dir function is quick.


    private Sub GetAllFolders(sPath as string)
    Dim FirstEntry as string

    on error resume next

    '//Make Sure Path Has A Trailing Backslash "\"
    If Right(sPath, 1) <> "\" then sPath = sPath & "\"

    '//Clear The List Box
    List1.Clear

    '//Retrieve The First Entry
    FirstEntry = Dir(sPath, vbDirectory)

    '//Loop Through All Entries And Find Folders Only
    Do While FirstEntry <> ""
    '//Ignore The Current Directory And The Encompassing Directory.
    If FirstEntry <> "." And FirstEntry <> ".." then
    '//Make Sure Entry is A Folder (Check Attributes)
    If (GetAttr(sPath & FirstEntry) And vbDirectory) = vbDirectory then
    '//Display Entries And Sizes
    List1.AddItem FirstEntry & " --> " & FileLen(sPath & FirstEntry)
    End If
    End If

    '//get The next Entry
    FirstEntry = Dir
    Loop

    End Sub




    Kris
    Software Engineer
    Phoenix,AZ
    Kris
    Software Engineer
    Phoenix, AZ USA

  6. #6
    Join Date
    Apr 2000
    Location
    South Carolina,USA
    Posts
    2,210

    Re: Listing Folders In A Network Location

    Look at this to see if it will help
    http://www.planetsourcecode.com/xq/A...s/ShowCode.htm
    '
    Also search on "Share Names" on Planet-Source-Code.com (without the quotes of course). You will get more than one hit.
    Try Http://www.Freevbcode.com as another source.

    John G

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

Featured