FileSystemWatcher

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello All,
I build an application which monitoring a directory located in my
network.This has done by using the FileSystemWatcher class, I successfully
got an event when files changed, renamed,deleted ..... , My problem is that
those information are not enough, since I can't know how done those changes.
So any one know how or have any example code which display/get the user
name/any other information that made the changes to this monitoring directory
????

Regards,
Joe
 
You have filters you can set :

/* Watch for changes in LastAccess and LastWrite times, and
the renaming of files or directories. */
watcher.NotifyFilter = NotifyFilters.LastAccess |
NotifyFilters.LastWrite
| NotifyFilters.FileName | NotifyFilters.DirectoryName;

Then, the eventargs parameter holds additional information you can get:

private static void OnChanged(object source, FileSystemEventArgs e)
{
// Specify what is done when a file is changed, created, or deleted.
Console.WriteLine("File: " + e.FullPath + " " + e.ChangeType);
}

private static void OnRenamed(object source, RenamedEventArgs e)
{
// Specify what is done when a file is renamed.
Console.WriteLine("File: {0} renamed to {1}", e.OldFullPath,
e.FullPath);
}


Username, doubt it. HTH

Peter
 
This exactly what I done , But my question is how to get the username or any
other information about the user, as in unix you can do somthing like:
ls -l filename | nawk '{print $3}.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top