How to identify the file has been created completely in c#..
Which command do we need to use to see that the file has been created completely.. some large file takes time to create completely how to identify them..
Thanks
How to identify the file has been created completely in c#..
Which command do we need to use to see that the file has been created completely.. some large file takes time to create completely how to identify them..
Thanks
The only method I know of is to try opening it to see if another process still has a hold on it, e.g.:
private static Boolean FileInUse(FileInfo file)
{
Boolean inUse = false;
try
{
using (file.OpenRead()) {}
}
catch (Exception exception)
{
inUse = true;
}
return inUse;
}
See similar discussion:
http://stackoverflow.com/questions/30074/monitoring-files-how-to-know-when-a-file-is-complete
private static Boolean FileInUse(FileInfo file)
{
Boolean inUse = false;
try
{
using (file.Open(FileMode.Open, FileAccess.ReadWrite, FileShare.None)) {}
}
catch (Exception exception)
{
inUse = true;
}
return inUse;
}