Is it possible in the Windows environment to detect if a file is being opened with with .NET
I would like to place a handler on the file system to detect if a file or any file is being opened, is this possible?
Is it possible in the Windows environment to detect if a file is being opened with with .NET
I would like to place a handler on the file system to detect if a file or any file is being opened, is this possible?
System.IO.FileSystemWatcher may be what you're looking for.
AFAIK there is no way to detect if a file was opened with .NET or otherwise.
The simplest solution would be to use a FileSystemWatcher
and set the filter to NotifyFilters.LastAccess
, which will tell it to watch for a change in the last access date/time.
Check out the FileSystemWatcher class
http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx
I'm not 100% sure that you can determine if a file is opened, but you can determine if a file is changed, created, deleted.
Hi Coppermill,
Some time ago I needed an app to monitor particular folder (and its subfolders) and raise an event if there was a new file created. I used FileWatcher Class. I'm pretty sure that its event 'changed' would work for you. It's nice and simple to implement. Check the sitets below for more info:
usethisaddress msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx
usethisaddres csharphelp.com/archives2/archive377.html
Hope this helps.
Damo