Answers for "watch file c#"

C#
0

how to use file watcher in c#

private void watch()
{
  FileSystemWatcher watcher = new FileSystemWatcher();
  watcher.Path = path;
  watcher.NotifyFilter = NotifyFilters.LastWrite;
  watcher.Filter = "*.*";
  watcher.Changed += new FileSystemEventHandler(OnChanged);
  watcher.EnableRaisingEvents = true;
}
Posted by: Guest on November-13-2020
0

c# file watcher

public MainWindow()
{
    InitializeComponent();

    FileSystemWatcher fsw = new FileSystemWatcher();
    fsw.Filter = "test1.csv";
    fsw.NotifyFilter = NotifyFilters.LastWrite;
    fsw.Path = "z:\\temp\\";
    fsw.Changed += Fsw_Changed;
    fsw.EnableRaisingEvents = true;    
}

private void Fsw_Changed(object sender, FileSystemEventArgs e)
{
    MessageBox.Show(e.FullPath);
}
Posted by: Guest on March-21-2022
0

c# file watcher specific file

watcher.Path = Path.GetDirectoryName(filePath1); 
watcher.Filter = Path.GetFileName(filePath1);
Posted by: Guest on November-20-2020

C# Answers by Framework

Browse Popular Code Answers by Language