-
FileSystemObject
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! :)
-
Never mind. I've got it.
Code:
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