Click to See Complete Forum and Search --> : FileSystemObject


enigmaos
June 6th, 2002, 10:13 AM
Does anybody know how to use FileSystemObject in VB.NET?

I'm trying to go into a folder/directory to loop through the files and within each file, look for a specific item.

Any sample code?

Or there's a differetn and better way of searching files?

Thanks! :)

enigmaos
June 6th, 2002, 11:23 AM
Never mind. I've got it.

Dim oFolder As Directory
Dim oFile As FileStream
Dim oReader As StreamReader
Dim sFilename As String()
Dim sContents As String
Dim i As Integer
sFilename = oFolder.GetFiles("C:\Directory\")

For i = 0 To UBound(sFilename)
oFile = New FileStream(sFilename(i), FileMode.OpenOrCreate, FileAccess.Read)
oReader = New StreamReader(oFile)
sContents = oReader.ReadToEnd
oReader.Close()

oReader = Nothing
oFile = Nothing
Next