file write flush?

cryinlion85

New member
Joined
Oct 2, 2007
Messages
2
Programming Experience
3-5
Hello,

I am using pslist to write to a log file, which i then read from to determine whether a remote process is running. however, when i read the file, the changes don't seem to take effect until after the function returns. i have tried a StreamWriter.Flush() (even though AutoFlush is set) as well as closing and re-opening the file.

VB.NET:
Dim shellString As String
Using SR As StreamWriter = New StreamWriter(CurDir() & "\listfeedback.txt", FileMode.OpenOrCreate)

shellString = "pslist \\" & str4Bat & " -u " & Tab2Data(indx).User & " -p " & Tab2Data(indx).Pass & " " & appName & " > " & CurDir() & "\listfeedback.txt"
File.WriteAllText(CurDir() & "\ListTask.bat", shellString)
Shell(CurDir() & "\ListTask.bat")
SR.Flush()
SR.Close()
SR.Dispose()
End Using

Dim line As String
Using SR As StreamReader = New StreamReader(CurDir() & "\feedback.txt")
line = SR.ReadLine()
SR.Close()
SR.Dispose()
End Using

if i put a break in the program (like a MsgBox or something) between the two "Using" sections, "feedback.txt" shows the old data, and it is updated only after the function returns (which is below the second "Using" section). any ideas are welcome.
 
Back
Top