FileSystemWatcher例子

来源:互联网 发布:贪吃蛇java代码 编辑:程序博客网 时间:2024/06/03 08:04
 class Program
    {
        static void Main(string[] args)
        {
            FileSystemWatcher wather = new FileSystemWatcher();
            wather.Path = "I:\\";
            wather.EnableRaisingEvents = true;
            wather.Created += new FileSystemEventHandler(ste);//当文件create时触发的事件
            Thread.Sleep(Timeout.Infinite);
        }


        public static void ste(object sender,FileSystemEventArgs e)
        {
            Console.WriteLine(e.FullPath);
        }
    }
}
0 0
原创粉丝点击