B
booksnore
Riddle me this... I have an app which listens to a windows folder for
files to appear and then processes the file based on the file format. My
question is if a really big file appears in the folder (say over 20 G)
then it takes more than 20 minutes for the file to be copied there. As
my listener job looks in the folder every 30 seconds I don't want to
process the file until the whole file is there - if you get what I mean.
The only way I think I have found to ensure that a file is a whole file
and not in the process of loading into the folder is to compare the
fileInfo LastAccessTime to the fileInfo CreationTime (below). I'm not
sure if this is really the correct way to go. Any one else come across
this problem or any ideas?
Hashtable fileList = new Hashtable();
DirectoryInfo di = new DirectoryInfo(dir);
FileInfo[] rgFiles = di.GetFiles(type);
foreach(FileInfo fi in rgFiles)
{
if (fi.LastAccessTime != fi.CreationTime)
{
string key = fi.Name.ToUpper() +
fi.Length.ToString().ToUpper()+fi.CreationTime.ToString("yyyyMMdd").ToUp
per();
fileList[key] = fi;
}
}
files to appear and then processes the file based on the file format. My
question is if a really big file appears in the folder (say over 20 G)
then it takes more than 20 minutes for the file to be copied there. As
my listener job looks in the folder every 30 seconds I don't want to
process the file until the whole file is there - if you get what I mean.
The only way I think I have found to ensure that a file is a whole file
and not in the process of loading into the folder is to compare the
fileInfo LastAccessTime to the fileInfo CreationTime (below). I'm not
sure if this is really the correct way to go. Any one else come across
this problem or any ideas?
Hashtable fileList = new Hashtable();
DirectoryInfo di = new DirectoryInfo(dir);
FileInfo[] rgFiles = di.GetFiles(type);
foreach(FileInfo fi in rgFiles)
{
if (fi.LastAccessTime != fi.CreationTime)
{
string key = fi.Name.ToUpper() +
fi.Length.ToString().ToUpper()+fi.CreationTime.ToString("yyyyMMdd").ToUp
per();
fileList[key] = fi;
}
}