My file watcher event read the first file only and then I get the following error: "Error: System.IO.IOException: The process cannot access the file 'D:\TREE\Dump\TF20141004011343313.txt' because it is being used by another process."
Here is my code:
int? msgID;
string dup ="";
try
{
//---------read from file------------
string block;
using (StreamReader sr = File.OpenText(MsgsPath + "\\" + e.Name))
{
block = sr.ReadToEnd();
}
and "using" should handle the open and close automatically, right? I then use this code to move processed files:
File.Move(MsgsPath + "\\" + e.Name, MsgsPath + "\\Archive\\" + e.Name);