zoukankan      html  css  js  c++  java
  • FileSystemWatcher.cs

    /*
     * C# Programmers Pocket Consultant
     * Author: Gregory S. MacBeth
     * Email: gmacbeth@comporium.net
     * Create Date: June 27, 2003
     * Last Modified Date:
     * Version: 1
     */
    using System;
    using System.IO;

    namespace Client.Chapter_11___File_and_Streams
    {
        public class Test
        {
            public static void Main(string[] args)
            {
                 FileSystemWatcher watcher = new FileSystemWatcher();
                 watcher.Path = @"c:\Test";
                 watcher.NotifyFilter  =
                                                        NotifyFilters.LastAccess |
                                                        NotifyFilters.LastWrite |
                                                        NotifyFilters.FileName |
                                                        NotifyFilters.DirectoryName;
                 watcher.Filter = "*.txt";
                 watcher.Changed += new FileSystemEventHandler(OnChanged);
                 watcher.Created += new FileSystemEventHandler(OnChanged);
                 watcher.Deleted += new FileSystemEventHandler(OnChanged);
                 watcher.Renamed += new RenamedEventHandler(OnRenamed);
                 watcher.EnableRaisingEvents = true;
                             
            }
            
            public static void OnChanged(object source, FileSystemEventArgs e)
            {
                   Console.WriteLine("Event Fired");
            }
            public static void OnRenamed(object source, RenamedEventArgs e)
            {
                Console.WriteLine("Event Fired");
            }
        
        }
    }
  • 相关阅读:
    如何解决js跨域问题
    Java Web系统常用的第三方接口
    webapi返回json格式,并定义日期解析格式
    华为手机打开Logcat的方法
    Kendo UI for ASP.NET MVC 的一些使用经验(转)
    adobe pro破解说明
    阿里云服务器添加解析域名
    tfs代码上传到server并下载到新位置
    kendo 级联加带搜索的下拉框以及js赋值
    函数进阶
  • 原文地址:https://www.cnblogs.com/shihao/p/2501876.html
Copyright © 2011-2022 走看看