HI, I use the FileSystemWatcher in c# to copy a file created by Biztalk to another directory, but it copies a zerop length file to the new dir. If I copy a file into the watched dir, it works ok, but not from biz...
I assume biztalk creates the file, fills it with data, then saves it. How would I be able to wait till it is ok to read the file?
Here is the code:
Code:
private void Form1_Load(object sender, System.EventArgs e)
{
fsWatcher.Path = @"C:\EDI\Orders\2_EDI_Output_3_IServer_Input";
fsWatcher.Created += new System.IO.FileSystemEventHandler(this.FileCreated);
// Begin watching.
fsWatcher.EnableRaisingEvents = true;
}
private void FileCreated(object sender, System.IO.FileSystemEventArgs e)
{
try
{
string myPath = e.FullPath;
string myFile = e.Name;
System.IO.FileInfo myFileInfo = new System.IO.FileInfo(myFile) ;
string myAttibs = myFileInfo.Attributes.ToString();
while (myFileInfo.Attributes.ToString() != "18446744073709551615")
{
string x = "waiting";
}
System.IO.File.Copy(myPath,@"C:\EDI\Aperaks\3_XML_Input\" + myFile,true);
}
catch (System.IO.IOException ex)
{
System.IO.IOException myex = ex;
}
catch (System.Exception ex)
{
System.Exception myex = ex;
}
}
Thanks
Enrico
iProc