I am using the fileSystemWatcher and the _Changed event to indicate what file that was LastWritten to in a folder and then I want to read this file.
It seems that the code that I have below is executing twice and the second time the code runs I get this error message.
I have tried other type of code that also indicates that the code executes twice. ?
Why does the code execute twice though I want to just execute one time.
Second is even if the code is executing twice the file shouldn´t be used as I am closing it ? and there is no other process that use the file.
"The process cannot access the file 'C:\\F1\\t1.txt' because it is being used by another process"
private: System::Void fileSystemWatcher1_Changed(System::Object^ sender, System::IO::FileSystemEventArgs^ e)
{
String^ RLine;
StreamReader^ ar;
ar = gcnew StreamReader(e->FullPath->ToString());
while( ar->Peek() >= 0 )
{
RLine = ar->ReadLine();
}
ar->Close();
}