zoukankan      html  css  js  c++  java
  • Filewatcher

    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace FileSystemWatcherLab
    {
        internal class Test1
        {
            public void Execute()
            {
                FileSystemWatcher watcher = new FileSystemWatcher();
                watcher.Path = "S:\Filewatcher";
                watcher.NotifyFilter = NotifyFilters.DirectoryName | NotifyFilters.FileName | NotifyFilters.LastWrite | NotifyFilters.Size;
                watcher.IncludeSubdirectories = true;
    
                watcher.Changed += this.OnChanged;
                watcher.Created += this.OnCreated;
                watcher.Deleted += this.OnDeleted;
                watcher.Renamed += this.OnRenamed;
    
                watcher.EnableRaisingEvents = true;
            }
    
            /// <summary>
            /// On path changed event.
            /// </summary>
            /// <param name="source">Changed source.</param>
            /// <param name="e">Path change event args.</param>
            private void OnCreated(object source, FileSystemEventArgs e)
            {
                Console.WriteLine("Created");
                Console.WriteLine(e.FullPath);
                Console.WriteLine();
            }
    
            /// <summary>
            /// On path changed event.
            /// </summary>
            /// <param name="source">Changed source.</param>
            /// <param name="e">Path change event args.</param>
            private void OnDeleted(object source, FileSystemEventArgs e)
            {
                Console.WriteLine("Deleted");
                Console.WriteLine(e.FullPath);
                Console.WriteLine();
            }
    
            /// <summary>
            /// On path changed event.
            /// </summary>
            /// <param name="source">Changed source.</param>
            /// <param name="e">Path change event args.</param>
            private void OnChanged(object source, FileSystemEventArgs e)
            {
                Console.WriteLine("Changed");
                Console.WriteLine(e.FullPath);
                Console.WriteLine();
            }
    
            /// <summary>
            /// On path rename event.
            /// </summary>
            /// <param name="source">Rename source.</param>
            /// <param name="e">Path rename args.</param>
            private void OnRenamed(object source, RenamedEventArgs e)
            {
                Console.WriteLine("Renamed");
                Console.WriteLine(e.FullPath);
                Console.WriteLine();
            }
        }
    }
    View Code
  • 相关阅读:
    java web 自定义错误页面 完整jsp错误页面代码(同时写错误日志) error.jsp
    linux ps命令详解
    Cocos2d-x MultipleTouch & CCControllButton's confusion
    android 处理图片之--bitmap处理
    JBoss 目录结构
    如何将Android默认的Camra程序导入到eclipse中
    SGU107——987654321 problem
    解析Systemtap
    csdn 刷分小工具(刷了1000多被封了,慎用)
    OpenCV——基本图形绘制(椭圆、圆、多边形、直线、矩形)
  • 原文地址:https://www.cnblogs.com/lierle/p/3394801.html
Copyright © 2011-2022 走看看