• 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
  • 相关阅读:
    json对象与字符串的相互转换,数组和字符串的转换
    angularjs ng-csv 异步下载
    angular2 localStorage的使用
    ng-csv 异步数据下载
    微信小程序AES加密解密
    微信小程序Md5加密(utf-8汉字无影响)
    angular-file-upload封装为指令+图片尺寸限制
    angular+require前端项目架构搭建
    Inspinia_admin-V2.3原版(英文)
    hplus--H+ V2.3 (中文版)
  • 原文地址:https://www.cnblogs.com/lierle/p/3394801.html
Copyright © 2020-2023  润新知