There are empty lines in the file im reading from so using
.peek -1 wont work. Any ideas how to get this loop to stop at the end of the file? Thanks in advance.
Dim textLine As String, fileName As String, dirName As String
Dim outPath as String
Dim fileDate As Date
Dim delim As Integer
Dim fs As FileStream, sr As StreamReader
Dim sW As StreamWriter, outs As FileStream
fs = New FileStream(sName, FileMode.Open, FileAccess.Read)
outs = New FileStream(outputFile, FileMode.Append)
sW = New StreamWriter(outs)
sr = New StreamReader(fs)
textLine = sr.ReadLine
Do While ???????
textLine = sr.ReadLine
textLine = Trim$(textLine)
If Len(textLine) > 0 Then
If Left$(textLine, 13) = "Directory of " Then
dirName = Mid$(textLine, 14)
Else
If dirName <> "" Then
If IsDate(Left(textLine, 8)) Then
fileDate = CDate(Left(textLine, 8))
If fileDate < dateRequired Then
delim = InStr(38, textLine, " ", _ CompareMethod.Text)
If delim > 0 Then
fileName = Trim$(Mid$(textLine, delim))
dirName = Replace(dirName, ":", "$")
outPath = dirName & "\" & fileName
sW.WriteLine(outPath)
End If
End If
End If
End If
End If
End If
Loop
sr.Close()
sW.Close()
.peek -1 wont work. Any ideas how to get this loop to stop at the end of the file? Thanks in advance.
Dim textLine As String, fileName As String, dirName As String
Dim outPath as String
Dim fileDate As Date
Dim delim As Integer
Dim fs As FileStream, sr As StreamReader
Dim sW As StreamWriter, outs As FileStream
fs = New FileStream(sName, FileMode.Open, FileAccess.Read)
outs = New FileStream(outputFile, FileMode.Append)
sW = New StreamWriter(outs)
sr = New StreamReader(fs)
textLine = sr.ReadLine
Do While ???????
textLine = sr.ReadLine
textLine = Trim$(textLine)
If Len(textLine) > 0 Then
If Left$(textLine, 13) = "Directory of " Then
dirName = Mid$(textLine, 14)
Else
If dirName <> "" Then
If IsDate(Left(textLine, 8)) Then
fileDate = CDate(Left(textLine, 8))
If fileDate < dateRequired Then
delim = InStr(38, textLine, " ", _ CompareMethod.Text)
If delim > 0 Then
fileName = Trim$(Mid$(textLine, delim))
dirName = Replace(dirName, ":", "$")
outPath = dirName & "\" & fileName
sW.WriteLine(outPath)
End If
End If
End If
End If
End If
End If
Loop
sr.Close()
sW.Close()