私は次のような方法を持っています
public void Run()
{
// Create a new FileSystemWatcher and set its properties.
FileSystemWatcher watcher = new FileSystemWatcher();
watcher.Path = "C:\\model_RCCMREC";
/* 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;
// watch wav files.
watcher.Filter = "*.wav";
// Add event handlers.
watcher.Created += new FileSystemEventHandler(OnChanged);
// Begin watching.
watcher.EnableRaisingEvents = true;
}
および Onchanged イベント ハンドラーを
public void OnChanged(object source, FileSystemEventArgs e)
{
//I AM DOING SOMETHNG HERE
}
新しいファイルがフォルダーに追加されるたびに、実際に Onchanged イベント ハンドラーを実行したいと考えています。新しいファイルの追加をシミュレートするために、テスト方法を実行しました
public void test()
{
File.Move(@"C:/TAKE_FORM_HERE_RCCM/59947874_59858856_03022013_074051_785_787_490_108.wav", @"C:/model_RCCMREC/59947874_59858856_03022013_074051_785_787_490_108.wav");
Run();
}
ただし、プログラムを実行すると、OnChanged イベント ハンドラに到達しません。
なぜそうなのですか?または私は何を間違っていますか?