Hello,
When I step through the following code snippet:
Dim di As DirectoryInfo = New DirectoryInfo(strMyPath)
Dim sr As StreamReader
If di.Exists Then
Dim fi As FileInfo
For Each fi In di.GetFiles("*.txt")
sr = fi.OpenText()
Dim SomeText As String
SomeText = sr.ReadToEnd()
If sr.ReadToEnd().ToUpper.IndexOf("mytext") > 0
Then
MsgBox("success")
End If
Next fi
If I put a break point on the "SomeText = sr.ReadToEnd()" line and view
the value of sr.ReadToEnd it says "" (empty string). However, on the
same breakpoint fi.OpenText().ReadToEnd shows me "mytext". As you can
see, I set "sr = fi.OpenText()" a couple lines about the "SomeText =
sr.ReadToEnd()" line. Any idea what's going on?
Thanks,
Eric