当前位置: 首页 > news >正文

广州手机网站建设公司哪家好化妆品网站建设方案

广州手机网站建设公司哪家好,化妆品网站建设方案,新闻自动采集网站源码,什么是响应式营销型网站建设利用 C# 中的 FileSystemWatcher 制作一个文件夹监控小工具独立观察员 2020 年 12 月 26 日前一段看到微信公众号 “码农读书” 上发了一篇文章《如何使用 C# 中的 FileSystemWatcher》#xff08;翻译自#xff1a;https://www.infoworld.com/article/3185447/how-to-work-w… 利用 C# 中的 FileSystemWatcher 制作一个文件夹监控小工具独立观察员 2020 年 12 月 26 日 前一段看到微信公众号 “码农读书” 上发了一篇文章《如何使用 C# 中的 FileSystemWatcher》翻译自https://www.infoworld.com/article/3185447/how-to-work-with-filesystemwatcher-in-c.html 其中简述了使用 FileSystemWatcher 进行文件系统变更监测的方法本人受此启发决定制作一个文件夹内变动监控的小工具当作练手和自用。目前该工具已制作完成故发文分享给大家。 功能比较简单运行程序后点击 “选择文件夹” 按钮选择想要监控的文件夹然后点击 “开始监控文件变动” 即可。可以检测 文件夹 / 文件 的创建、删除、修改、重命名然后在信息窗中输出相关信息。如果取消勾选 “是否显示完全路径”则输出的信息中将不包含选择的 “文件夹路径” 部分也就是显示的是相对路径。如果取消勾选 “是否监控子文件夹”则程序将不监控子文件夹内的变动情况。 保存配置按钮可进行保存如下信息下次打开程序会恢复保存的状态 关键代码如下文末会给出代码仓库地址#region 文件夹监控private FileSystemWatcher _FileSystemWatcher new FileSystemWatcher();// 参考https://www.infoworld.com/article/3185447/how-to-work-with-filesystemwatcher-in-c.html/// summary /// 开始监控目录 /// /summary /// param namepath 目录路径 /param /// param nameisIncludeSubDir 是否包括子目录 /param private async void MonitorDirectory(string path, bool isIncludeSubDir true) {_FileSystemWatcher.EnableRaisingEvents false;_FileSystemWatcher new FileSystemWatcher();_FileSystemWatcher.Path path;_FileSystemWatcher.IncludeSubdirectories isIncludeSubDir;_FileSystemWatcher.Created FileSystemWatcher_Created;_FileSystemWatcher.Renamed FileSystemWatcher_Renamed;_FileSystemWatcher.Deleted FileSystemWatcher_Deleted;_FileSystemWatcher.Changed FileSystemWatcher_Changed;// 开始监控_FileSystemWatcher.EnableRaisingEvents true;await ConfirmBoxHelper.ShowMessage(DialogVm, $ 已开启监控[{Configs.FolderPath}]); }private void FileSystemWatcher_Changed(object sender, FileSystemEventArgs e) {Console.WriteLine($【{GetPathType(e.FullPath)} 更改】{GetPath(e)}); }private void FileSystemWatcher_Created(object sender, FileSystemEventArgs e) {Console.WriteLine($【{GetPathType(e.FullPath)} 创建】{GetPath(e)}); }private void FileSystemWatcher_Renamed(object sender, FileSystemEventArgs e) {Console.WriteLine($【{GetPathType(e.FullPath)} 重命名】{GetOldPath((RenamedEventArgs)e)} -- {GetPath(e)}); }private void FileSystemWatcher_Deleted(object sender, FileSystemEventArgs e) {Console.WriteLine($【{GetPathType(e.FullPath)} 删除】{GetPath(e)}); }/// summary /// 获取变动的路径的显示字符串 /// /summary private string GetPath(FileSystemEventArgs e) {if (Configs.IsShowFullPath){return e.FullPath;}return e.Name; }/// summary /// 获取原先路径的显示字符串 /// /summary private string GetOldPath(RenamedEventArgs e) {if (Configs.IsShowFullPath){return e.OldFullPath;}return e.OldName; }#endregion#region 判断是文件还是文件夹/// summary /// 获取路径类型判断是文件还是文件夹 /// /summary /// param namepath 路径 /param /// returnsPathTypeEnum/returns public static PathTypeEnum GetPathType(string path) {if (File.Exists(path)){return PathTypeEnum. 文件}else if (Directory.Exists(path)){return PathTypeEnum. 文件夹}else{return PathTypeEnum. 不存在} }/// summary /// 路径类型枚举 /// /summary public enum PathTypeEnum {文件文件夹不存在 }#endregion值得注意的就是FileSystemWatcher 开启和关闭监控是通过 EnableRaisingEvents 这个 bool 属性进行控制的。然后就是主要的四个事件增、删、改、重命名分别指定好回调方法_FileSystemWatcher.Created FileSystemWatcher_Created; _FileSystemWatcher.Renamed FileSystemWatcher_Renamed; _FileSystemWatcher.Deleted FileSystemWatcher_Deleted; _FileSystemWatcher.Changed FileSystemWatcher_Changed;还有一点就是其它事件的参数都是 FileSystemEventArgs 类型而重命名事件的独有参数是 RenamedEventArgs 类型这个是前者的子类多了旧的文件名和路径等信息。 程序和代码都展示完了又到了和大家说再见的时刻了在此附上代码地址和另一篇参考文章吧代码地址https://gitee.com/dlgcy/DLGCY.FilesWatcher发行版地址https://gitee.com/dlgcy/DLGCY.FilesWatcher/releases又一参考《FileSystemWatcher 用法详解》https://blog.csdn.net/hwt0101/article/details/8469285里面也有个监控软件不过我没下载大家可以试试待更新目前信息窗口信息多的话会触发 “灭霸模式”后面考虑加个开关。  好了就到这里吧谢谢阅读。
http://www.yutouwan.com/news/231046/

相关文章:

  • 开发网站需要哪些技术人员零售电商
  • 网站建设新闻发布聊城市住房和城乡建设局网站
  • 网站被墙的原因市场调研公司
  • 有专门做辩论的网站吗自己做项目的网站
  • 黑色网站模版苏州网站建设优化过哦
  • 建立网站时首先考虑的问题华夏业务员做单的网站
  • 网站地图怎么做_济南产品网站建设外包
  • 做网站内容软件wordpress 修改程序文件
  • 百度网站地址提交浙江网站建设哪家专业
  • 网站虚拟主机公司国内做seo公司简介
  • 长沙做门户网站的公司wordpress one touch 下载
  • 镇江网站设计制作邢台网约车新政策
  • 上海建设银行网站上班时间带数字 网站 域名
  • 如何用快站做pc端网站哈尔滨网站小程序制作
  • 手机网站改版公司加盟淘宝网站做阳光棚多少钱一平米
  • 大连中小网站建设公司网站开发管理制度
  • h5网站开发价格黄页网站建设
  • 怎样给自己的网站做防红连接5个搜索引擎作弊的网站
  • 定州网站建设wordpress 回复后查看
  • wordpress网站seo设置人工智能写作网站
  • 新网站如何做seo推广wordpress mysql 密码
  • 东莞定制网站开发重庆商城网站开发
  • 医疗网站建设服务自己做副业可以抢哪个网站
  • 建设网站选多大的空间合适wordpress演示站功能
  • 网站建设对接视频江苏建设集团有限公司网站
  • 河南省建设工程注册中心网站旅游电子商务的三创赛网站建设
  • 怎么做自己的cms导购网站著名的网络营销案例
  • 淅川微网站建设郑州商城网站设计
  • 厦门广告公司网站建设上海建设厅网站查询
  • 在国税网站更换购票员怎么做dw怎么做班级网站