A
Anders Eriksson
Hello!
I'm trying to create a program that will watch a directory and when a file
is created print that file. I have used FileSystemWatcher for watching the
directory and I get an created event.
The problem is that I don't know when the file is complete when using
Explorer copy or move.
I have tried to use FileIOPermission but I always get that the file is
unlocked.
How do I check for file complete?
// Anders
--
English isn't my first, or second, language.
So anything rude or strange are due to the translation
private static bool isFileLocked(string path)
{
FileIOPermission _available = new FileIOPermission( PermissionState.None);
// blank slate
try
{
_available.SetPathList( FileIOPermissionAccess.Write, path);
_available.Demand( ); // does file permit shared writing?
Console.WriteLine("isFileLocked: false ");
return false;
}
catch ( SecurityException _se)
{
Console.WriteLine("isFileLocked: true ");
return true;
}
}
I'm trying to create a program that will watch a directory and when a file
is created print that file. I have used FileSystemWatcher for watching the
directory and I get an created event.
The problem is that I don't know when the file is complete when using
Explorer copy or move.
I have tried to use FileIOPermission but I always get that the file is
unlocked.
How do I check for file complete?
// Anders
--
English isn't my first, or second, language.
So anything rude or strange are due to the translation
private static bool isFileLocked(string path)
{
FileIOPermission _available = new FileIOPermission( PermissionState.None);
// blank slate
try
{
_available.SetPathList( FileIOPermissionAccess.Write, path);
_available.Demand( ); // does file permit shared writing?
Console.WriteLine("isFileLocked: false ");
return false;
}
catch ( SecurityException _se)
{
Console.WriteLine("isFileLocked: true ");
return true;
}
}