Help WIth Directory Listings

digital
01-13-2004, 07:22 PM
I'm looking for the VisualBasic .Net equivalent to:

"dir *.mp3"

I know that I can accomplish this by creating a batch file, but I was wondering if there was an easier way to get just a simple listing of the files in the specified directory.


Thnx in advance.

Iceplug
01-13-2004, 07:30 PM
Try the shared function...
System.IO.Directory.GetFiles(path)
It returns an array of strings with the name of all the files :).

digital
01-13-2004, 08:28 PM
Let's say that I am searching my C:\ for all my .mp3 files so I can list them on a web page for people to see. Here is what I have now.

objStreamWriter = System.IO.File.AppendText("C:\generated.html)
objStreamWriter.WriteLine("<html><head><title>Generated File List</title></head>")
objStreamWriter.WriteLine("<body>")
objStreamWriter.WriteLine(System.IO.Directory.GetFiles("C:\*.mp3"))
objStreamWriter.WriteLine("</body>")
objStreamWriter.Close()

The problem I'm having is getting objStreamWriter.WriteLine(System.IO.Directory.GetFiles("C:\*.mp3")) to give me the desired output.

Thnx.

OnErr0r
01-13-2004, 09:24 PM
Since it's returning an array, you'll want to write a loop and increment through the array outputting it's items to the webpage.

digital
01-13-2004, 10:06 PM
Heh, I never even thought of that, thanks alot to both of you guys ;).

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum