Search results for 'FileSystemEventArgs'. 1 post(s) found.
Create a new project and add a form to it. Put a button on the form called button1 then add this code.
using System.IO;
private void button1_Click(object sender, System.EventArgs e)
{
FileSystemWatcher objFSW = new FileSystemWatcher();
objFSW.Path = "c:\\";
objFSW.Filter = "*.*";
objFSW.NotifyFilter = NotifyFilters.LastAccess |
NotifyFilters.LastWrite |
NotifyFilters.FileName |
NotifyFilters.DirectoryName;
//Setup Events
objFSW.Changed = new FileSystemEventHandler(FileChanged);
objFSW.Created = new FileSystemEventHandler(FileCreated);
objFSW.Deleted = new FileSystemEventHandler(FileDeleted);
objFSW.Renamed = new RenamedEventHandler(FileRenamed);
//Start Things up
objFSW.EnableRaisingEvents = true;
}
public static void FileChanged(object source, FileSystemEventArgs e)
{
Console.WriteLine("File {0} was Changed.",e.FullPath);
}
public static void FileCreated(object source, FileSystemEventArgs e)
{
Console.WriteLine("File {0} was Created.",e.FullPath);
}
public static void FileDeleted(object source, FileSystemEventArgs e)
{
Console.WriteLine("File {0} was Deleted.",e.FullPath);
}
public static void FileRenamed(object source, RenamedEventArgs e)
{
Console.WriteLine("File {0} was renamed to {1}", e.OldFullPath, e.FullPath);
}
private void button1_Click(object sender, System.EventArgs e)
{
FileSystemWatcher objFSW = new FileSystemWatcher();
objFSW.Path = "c:\\";
objFSW.Filter = "*.*";
objFSW.NotifyFilter = NotifyFilters.LastAccess |
NotifyFilters.LastWrite |
NotifyFilters.FileName |
NotifyFilters.DirectoryName;
//Setup Events
objFSW.Changed = new FileSystemEventHandler(FileChanged);
objFSW.Created = new FileSystemEventHandler(FileCreated);
objFSW.Deleted = new FileSystemEventHandler(FileDeleted);
objFSW.Renamed = new RenamedEventHandler(FileRenamed);
//Start Things up
objFSW.EnableRaisingEvents = true;
}
public static void FileChanged(object source, FileSystemEventArgs e)
{
Console.WriteLine("File {0} was Changed.",e.FullPath);
}
public static void FileCreated(object source, FileSystemEventArgs e)
{
Console.WriteLine("File {0} was Created.",e.FullPath);
}
public static void FileDeleted(object source, FileSystemEventArgs e)
{
Console.WriteLine("File {0} was Deleted.",e.FullPath);
}
public static void FileRenamed(object source, RenamedEventArgs e)
{
Console.WriteLine("File {0} was renamed to {1}", e.OldFullPath, e.FullPath);
}
Another posts included in "C#"
| Interacting With TinyPic From C# (0) | 2007/08/27 |
| How to send binary data through C# CGI app? (0) | 2007/08/27 |
| Simple C# CGI working on Apache (0) | 2007/08/27 |
| Calling Your Main Thread From A Worker Thread In C# (0) | 2007/08/27 |
| HashTable Tutorial In C# (0) | 2007/08/27 |
| Stack Tutorial In C# (0) | 2007/08/27 |
| Queue Tutorial In C# (0) | 2007/08/27 |
| Create PDF Files On the Fly In C Sharp (0) | 2007/08/27 |
Trackback : Cannot send a trackbact to this post.
-
Subject different money making ideas
2010/01/29 03:47
moneyideas
-
Subject different money making ideas
2010/01/29 12:50
moneyideas
-
Subject different money making ideas
2010/01/31 16:44
moneyideas

Prev

Rss Feed