Press any key to quit
Users Online
· Guests Online: 52
· Members Online: 0
· Total Members: 188
· Newest Member: meenachowdary055
· Members Online: 0
· Total Members: 188
· Newest Member: meenachowdary055
Forum Threads
Newest Threads
No Threads created
Hottest Threads
No Threads created
Latest Articles
Articles Hierarchy
C# Program to Trap Events from File
C# Program to Trap Events from File
This C# Program to Trap Events from File. Here the events that happen in the specified locations are trapped.
Here is source code of the C# Program to Trap Events from File. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.
-
/*
-
* C# Program to Trap Events from File
-
*/
-
using System;
-
using System.IO;
-
class Test
-
{
-
static void namechang(object sender, RenamedEventArgs evn)
-
{
-
Console.WriteLine("{0} NameChanged to {1}", evn.OldFullPath, evn.FullPath);
-
}
-
static void changed(object sender, FileSystemEventArgs evn)
-
{
-
Console.WriteLine(evn.FullPath + " " + evn.ChangeType);
-
}
-
static void Main(string[] arg)
-
{
-
FileSystemWatcher w = new FileSystemWatcher();
-
w.Path = "d:\\srip";
-
w.NotifyFilter = NotifyFilters.FileName | NotifyFilters.DirectoryName |
-
NotifyFilters.LastAccess | NotifyFilters.LastWrite;
-
w.Filter = "";
-
w.Created += new FileSystemEventHandler(changed);
-
w.Deleted += new FileSystemEventHandler(changed);
-
w.Changed += new FileSystemEventHandler(changed);
-
w.Renamed += new RenamedEventHandler(namechang);
-
w.EnableRaisingEvents = true;
-
Console.WriteLine("Press any key to quit");
-
Console.Read();
-
}
-
}
Here is the output of the C# Program:
Comments
No Comments have been Posted.
Post Comment
Please Login to Post a Comment.