Hi Subhash,
I'm not quite sure what you mean by "currently active file", but if you want to get notified of file changes, renames, moves and deletions on way to go is to use the FileSystemWatcher class. It lets you handle all these kind of events.
Example:
class Program
{
private static FileSystemWatcher fw;
static void Main(string[] args)
{
String path = args[0];
String filter = args[1];
fw = new FileSystemWatcher(path, filter);
fw.Deleted += new FileSystemEventHandler(fw_Deleted);
fw.NotifyFilter = NotifyFilters.Attributes | NotifyFilters.CreationTime |
NotifyFilters.DirectoryName | NotifyFilters.FileName |
NotifyFilters.LastAccess | NotifyFilters.LastWrite |
NotifyFilters.Security | NotifyFilters.Size;
fw.IncludeSubdirectories = true;
fw.EnableRaisingEvents = true;
Console.ReadLine();
}
static void fw_Deleted(object sender, FileSystemEventArgs e)
{
Console.WriteLine("{3:yyyy-MM-ddTHH:mm:ss.ffff} Deleted event: {0} {1} {2}", e.Name, e.FullPath, e.ChangeType, DateTime.Now);
}
}
This console application takes two command line parameters:
1. the path to watch e.g. c:\temp
2. which file extentions e.g. *.txt
Cheers
Manfred