Results 1 to 4 of 4

Thread: Getting a directory listing

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2002
    Posts
    158

    Question Getting a directory listing

    I know that I can use GetFiles to get a listing of the files in a directory. However, this command seems to just return a collection of strings with the file names. What command can I use that will provide both the files' names and the types of the files, i.e., file, directory, link, etc?

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: Getting a directory listing


  3. #3

    Thread Starter
    Addicted Member
    Join Date
    May 2002
    Posts
    158

    Re: Getting a directory listing

    Good call. Here’s a simplified version of my code:

    Code:
        Sub Main()
            Dim DI As New DirectoryInfo(basePath)
            Dim allItems() As FileSystemInfo = DI.GetFileSystemInfos()
            Dim Item As FileSystemInfo
            For Each Item In allItems
                <value> = fileAttr(Item.Attributes)
            Next
        End Sub
    
        Function fileAttr(ByVal attrVal As Integer) As XXX
            If (attrVal And FILE_ATTRIBUTE_READONLY) = FILE_ATTRIBUTE_READONLY Then <val> = ??
            <etc>
            Return <val>
        End Function
    Only one more question: I found no file attributes to indicate if a file is a shortcut (in Linux-eze, symbolic link). Anyway to figure this out?

  4. #4
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: Getting a directory listing


Tags for this Thread

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