FileSystemWatcher无法与NAS共享一起使用 [英] FileSystemWatcher not working with NAS Share

查看:59
本文介绍了FileSystemWatcher无法与NAS共享一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试监视正在创建和修改的文本文件在NAS共享中的文件夹和子文件夹.如果我尝试监视一个文件夹,则以下代码可以正常工作.但是当我尝试监视多个文件夹和子文件夹时, 以下代码不会引发任何事件.我已验证访问权限,并且可以完全访问共享中的文件夹和子文件夹.

I'm trying to monitor the folders and sub folders that are located in NAS share for the text files that are getting created and modified. The below code works fine if I try to monitor one folder. But when I tried to monitor multiple folders and sub folders, the below code does not raise any event. I verified my access and I have full access to the folders and sub folders in the share.

代码段

var _watcher = new FileSystemWatcher();           

_watcher.Path = @"z:\ TestFolder";           

_watcher.Path = @"z:\TestFolder";           

_watcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite               

_watcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite               

| NotifyFilters.FileName | NotifyFilters.DirectoryName; ;           

| NotifyFilters.FileName | NotifyFilters.DirectoryName; ;           

_watcher.IncludeSubdirectories = true;            _watcher.Filter ="* .txt";           

_watcher.IncludeSubdirectories = true;            _watcher.Filter = "*.txt";           

_watcher.Created + = new FileSystemEventHandler((x,y)=> Console.WriteLine("Created"));           

_watcher.Created += new FileSystemEventHandler((x, y) => Console.WriteLine("Created"));           

_watcher.Changed + = new FileSystemEventHandler((x,y)=> Console.WriteLine("Changed"));           

_watcher.Changed += new FileSystemEventHandler((x, y) => Console.WriteLine("Changed"));           

_watcher.Deleted + = new FileSystemEventHandler((x,y)=> Console.WriteLine("Deleted"));           

_watcher.Deleted += new FileSystemEventHandler((x,y) => Console.WriteLine("Deleted"));           

_watcher.Renamed + = new RenamedEventHandler((x,y)=> Console.WriteLine("Renamed")));           

_watcher.Renamed += new RenamedEventHandler((x, y) => Console.WriteLine("Renamed"));           

_watcher.Error + = new ErrorEventHandler((x,y)=> Console.WriteLine("Error")));           

_watcher.Error += new ErrorEventHandler((x, y) => Console.WriteLine("Error"));           

_watcher.EnableRaisingEvents = true;

_watcher.EnableRaisingEvents = true;

推荐答案

您好

Hi Sri18,

您使用什么.net框架?

What's the .net framework do you use?

这是一个类似的线程

那个家伙说,这可能是.NET v3.5的FileSystemWatcher的局限性.

The guy said it might be the limitation of FileSystemWatcher of .NET v3.5.

请尝试使用其他.Net框架进行测试.

Please try to use other .Net framework to test.

请同时发布测试结果在这里,谢谢.

Please also post the  test result here, thanks.

如果存在与FileSystemWatcher相关的问题或错误,我怀疑

I doubt that if there is a issue or bug related to FileSystemWatcher

最诚挚的问候,

克里斯汀


这篇关于FileSystemWatcher无法与NAS共享一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆