ファイルの変更を監視するための小さなアプリを作成しました。実行すると、パスに関する例外が発生するたびに。そして、私はその理由を理解できません。パスは実際に存在します。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Run();
}
public static void Run()
{
FileSystemWatcher watcher = new FileSystemWatcher();
watcher.Path = @"D:\test\1.txt";
watcher.NotifyFilter = NotifyFilters.LastWrite;
watcher.Changed +=new FileSystemEventHandler(watcher_Changed);
watcher.EnableRaisingEvents = true;
}
static void watcher_Changed(object sender, FileSystemEventArgs e)
{
Console.WriteLine(e.ChangeType);
}
}
}