Directory.GetFiles

tehon3299

Well-known member
Joined
Jan 6, 2003
Messages
155
Location
Liverpool, NY
I am using this method to get all the files in a directory:

Code:
Dim sFiles() As String = System.IO.Directory.GetFiles("C:\")

How do I print out all of the names in sFiles?

Thanks
 
By looping through the array. Im sure there are examples of this in the help file.
 
Code:
        Dim sFile As String

        For Each sFile In sFiles
            Debug.WriteLine(sFile)
        Next
 
I would guess Response.Write. If this was an ASP.NET question it should have been posted in that forum.
 
Directory Filenames

I am using the following code to get the files in a directory.

Code:
			Dim sFiles() As String = System.IO.Directory.GetFiles("C:\Documents and Settings\matt\Desktop\Songs\", "*.mp3")

Is there anyway to return JUST the filename and not the whole path?

Thanks
 
For a string containing a full path, you can use System.IO.Path.GetFilename() to extract just that portion of it.
 
Back
Top