XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFEExtension

【DLL】XFE各类拓展是一个C#的DLL库,旨在优化C#代码中常用语句的使用,并提供更简洁的访问方式,同时提供Xunit测试框架,快速搭建服务器/客户端,免费ChatGPTAPI接口,免费通讯服务器,XFE下载器,新增格式等

公开
关注 0 Fork 0 Star 0
返回提交历史

XFEstudio/XFEExtension

修复XFE文件监视器的bug

aac4407
XFE工作室室长 <mail@xfegzs.com>
提交于

代码差异

1 个文件 +19 -9
Modified XFE各类拓展.NetCore/FileExtension/XFEFileWatcher.cs +19 -9
@@ -130,24 +130,34 @@ public class XFEFileWatcher
130 130 {
131 131 if (Path is not null && Path != string.Empty)
132 132 {
133 if (File.Exists(Path) || Directory.Exists(Path))
133 FileSystemWatcher rootWatcher;
134 if (Directory.Exists(Path))
134 135 {
135 if (WatchSubdirectories && Directory.Exists(Path))
136 if (WatchSubdirectories)
136 137 {
137 138 MonitorSubdirectories(Path);
138 139 }
139 FileSystemWatcher rootWatcher = new(Path);
140 watchers.Add(rootWatcher);
141 rootWatcher.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName;
142 rootWatcher.Changed += OnFileChanged;
143 rootWatcher.Created += OnFileChanged;
144 rootWatcher.Deleted += OnFileChanged;
145 rootWatcher.Renamed += OnFileRenamed;
140 rootWatcher = new(Path);
141
142 }
143 else if (File.Exists(Path))
144 {
145 rootWatcher = new(System.IO.Path.GetDirectoryName(Path)!)
146 {
147 Filter = System.IO.Path.GetFileName(Path)
148 };
146 149 }
147 150 else
148 151 {
149 152 throw new XFEExtensionException("文件或文件夹不存在");
150 153 }
154 watchers.Add(rootWatcher);
155 rootWatcher.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName;
156 rootWatcher.Changed += OnFileChanged;
157 rootWatcher.Created += OnFileChanged;
158 rootWatcher.Deleted += OnFileChanged;
159 rootWatcher.Renamed += OnFileRenamed;
160 rootWatcher.EnableRaisingEvents = true;
151 161 }
152 162 else
153 163 {