I am curious. If I am using a combination of streamreader and streamwriter is there a way that I can have a stream written only if File X has been modified?
This code may not be constructed in the best way. It is attached to help in getting my questions accross.
sCommand = "whoami.exe >> C:\Desktop\Test.txt"
Using swrr As New StreamWriter(File.Open(ErrorLog, FileMode.OpenOrCreate))
For Each strUserName As String In strLines
Shell("cmd.exe /c" & sCommand, AppWinStyle.Hide, True, )
'command Cannot Execute, List Why and Move onto Next Command
Using sr As New StreamReader(File.Open(Test.txt, FileMode.OpenOrCreate))
If '''??File has been modifed??''''' Then swrr.WriteLine("PASS") Else swrr.WriteLine("FAIL")
End Using
Next
End Using
You can call
File.ReadAllText(path)to get a string containing the text.You can then compare the new string to the old one.
The correct way to read the output of a command is to use the
Processclass withRedirectStandardOutput.You can then create a
StreamReaderaroundStandardOutputand callReadToEnd().