jjzjj

fileWatcher

全部标签

c# - .net FileSystemWatcher 不拾取移动的文件夹

我发现有很多关于移动的文件的讨论(我对此没有问题),但没有任何特定于移动的文件夹的讨论(因此有这篇文章)。我有一个FileSystemWatcher实例化如下:varfileWatcher=newFileSystemWatcher("C:\\mypath");fileWatcher.IncludeSubdirectories=true;fileWatcher.NotifyFilter=NotifyFilters.LastWrite|NotifyFilters.FileName|NotifyFilters.CreationTime|NotifyFilters.Size;fileWatch

c++ - 等待 WaitForMultipleObjects

我正在尝试为我的FileWatcher类编写单元测试。FileWatcher派生自Thread类并使用WaitForMultipleObjects在其线程过程中等待两个句柄:从FindFirstChangeNotification返回的句柄让我取消上述等待的事件句柄。所以基本上FileWatcher正在等待最先发生的事情:文件更改或者我告诉它停止监视。现在,在尝试编写测试此类的代码时,我需要等待它开始等待。伪代码:FileWatcher.Wait(INFINITE)ChangeFile()//VerifythatFileWatcherworks(withsomeotherevent-u

c# - FileSystemWatcher - 如何将输出通过管道传输到文本文件?

我正在使用FileSystemWatcher类。我正在尝试将输出通过管道传输到文本文件。我已经添加了StreamWriterfileWriter=newStreamWriter("test.txt");但没有任何输出到文件!我哪里错了?classProgram{staticvoidMain(string[]args){stringdirPath="C:\\";FileSystemWatcherfileWatcher=newFileSystemWatcher(dirPath);fileWatcher.IncludeSubdirectories=true;fileWatcher.Filte

c# - FileSystemWatcher 类 - 简单问题

我目前正在研究FileSystemWatcher类,想知道如何指定目录路径,而且它的所有子文件都是文件夹。所以它会在C:\例如的任何地方寻找任何变化C:\ProgramFiles\test等stringDirPath="C:\\*.*";我尝试将.添加到directroy路径,但没有成功源代码如下:staticvoidMain(string[]args){stringDirPath="C:\\*.*";FileSystemWatcherFileWatcher=newFileSystemWatcher(DirPath);FileWatcher.Changed+=newFileSystem

C# 帮助 - FileSystemWatcher 类

我有以下代码,尽管我正在尝试输出:fileWriter.Write(e.OldName+"wasrenamedto"+e.Name+Environment.NewLine);虽然我得到以下错误:名称“e”在当前上下文中不存在我的代码如下:usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.IO;namespaceFileWatcherr{classProgram{staticvoidMain(string[]args){stringdirPath="C:\\"

c# - FileSystemWatcher Dispose 调用挂起

我们刚刚开始遇到FileSystemWatcher的一个奇怪问题,其中对Dispose()的调用似乎挂起。这段代码已经运行了一段时间没有任何问题,但我们刚刚升级到.NET3.5SP1,所以我想看看是否有其他人看到过这种行为。下面是创建FileSystemWatcher的代码:if(this.fileWatcher==null){this.fileWatcher=newFileSystemWatcher();}this.fileWatcher.BeginInit();this.fileWatcher.IncludeSubdirectories=true;this.fileWatcher.

c# - .Net FileWatcher 无法处理 ~80 多个文件

我正在使用.net2.0filewatcher来监视文件夹中的新文件。它工作得很好,除非我一次放置超过80个文件。该事件不再触发。就好像filewatcher被设置为跟踪一定数量的文件。目前我已经要求用户一次不要放置超过50个文件,这似乎可行,但我想修复它,以便可以一次将数百个文件放入文件夹中。这是我在事件中使用的代码。这是非常标准的东西,没什么特别的。FileWatcher=newFileSystemWatcher();FileWatcher.Path=ConfigurationManager.AppSettings["FolderOfFilesToWatch"];FileWatch

c# - FileSystemWatcher 是否创建自己的线程?

我希望这项工作在不同的线程中完成,但我必须创建一个线程还是它在不同的线程中完成所有工作?喜欢:ThreadfileThread=newThread(()=>{FileWatcher=newFileSystemWatcher();FileWatcher.Created+=OnFileEvent;FileWatcher.Deleted+=OnFileEvent;FileWatcher.Renamed+=OnRenameEvent;FileWatcher.EnableRaisingEvents=true;});fileThread.Start(); 最佳答案

ios - watchAppExtension 中的 NSUserDefault 更改通知处理

我正在创建一个Watch应用程序,以便在用户点击iPhone/主机应用程序中的表格View时在watch上显示一个值。我想收到有关共享UserDefault值更改的通知。它在WatchKit应用程序和iOS(主机)应用程序之间共享,因此当用户在主机应用程序中进行任何更改时,我希望收到通知。我做了以下事情:当用户在应用程序(主机应用程序)中执行某些操作时:NSUserDefaults*shared=[[NSUserDefaultsalloc]initWithSuiteName:@"group.app"];idobject=[self.plantsArrayobjectAtIndex:[

c# - .NET filesystemwatcher - 它是文件还是目录?

有没有办法通过FSW确定文件或目录是否已被删除? 最佳答案 这是弗莱彻解决方案的简化和更正版本:namespaceWatcher{classProgram{privateconststringDirectory=@"C:\Temp";privatestaticFileSystemWatcher_fileWatcher;privatestaticFileSystemWatcher_dirWatcher;staticvoidMain(string[]args){_fileWatcher=newFileSystemWatcher(Dire
12