| re: How do I best monitor a selected folder (and subfolder) for changes?
The below code monitors for xml file, you could modify and use it how u need
it
fsWatcher = new System.IO.FileSystemWatcher(strDirectoryName);
fsWatcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite
| NotifyFilters.FileName | NotifyFilters.DirectoryName;
fsWatcher.Filter = "*.xml";
fsWatcher.Created += new FileSystemEventHandler(OnNewFileAdded);
fsWatcher.Changed += new FileSystemEventHandler(OnFileChanged);
fsWatcher.EnableRaisingEvents = true;
public void OnNewFileAdded(object source, FileSystemEventArgs e)
{
//Your code
}
public void OnFileChanged(object source, FileSystemEventArgs e)
{
//Your code
}
--
Tarkeshwar L
..Net Programmer
Fifth Generation Technologies
"Egil Hansen" <egil@dailyrush.dk> wrote in message
news:1099388449.134079.112440@z14g2000cwz.googlegr oups.com...[color=blue]
> Hi all
>
> Do C# and .net have some way to monitor a folder in Windows XP/Windows
> 2000. I want to mirror the content of the folder, including subfolders
> (if any exsists) to another place, and I want to mirror the changes as
> they happen.
>[/color] |