我怎么知道文件夹内容的变化? [英] How can I know changes of folder's content?

查看:103
本文介绍了我怎么知道文件夹内容的变化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何知道文件夹内容的更改?如:新文件或文件夹是创建,修改,删除...?

解决方案

来自MSDN [ ^ ]

使用 FileSystemWatcher [ ^ ]以监视指定目录中的更改。您可以监视指定目录的文件和子目录中的更改。该组件可以在本地计算机,网络驱动器或远程计算机上观看文件。



在此处查看类似文章:

< a href =http://www.codeproject.com/Articles/26528/C-Application-to-Watch-a-File-or-Directory-using-F> C#:使用FileSystem监视文件或目录的应用程序观察者 [ ^ ]。

同时检查:如何:获取有关文件,文件夹和驱动器的信息(C#编程指南) [ ^ ]





- Amit


如果要捕获相关事件,可以使用类 System.IO.FileSystemWatcher

http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx [ ^ ]。



但是,这里有一些警告:

FileSystemWatcher - Pure Chaos(第1部分,共2部分) [ ^ ],

FileSystemWatcher - Pure Chaos(第2部分,共2部分) [ ^ ]。



-SA

How can I know changes of folder's content? Such as: New file(s) or folder(s) are create, modify, delete... ?

解决方案

From MSDN[^]
Use FileSystemWatcher[^] to watch for changes in a specified directory. You can watch for changes in files and subdirectories of the specified directory. The component can watch files on a local computer, a network drive, or a remote computer.

Check a similar article here:
C#: Application to Watch a File or Directory using FileSystem Watcher[^].
Also check : How to: Get Information About Files, Folders, and Drives (C# Programming Guide)[^]


--Amit


If you want to capture related events, you can use the class System.IO.FileSystemWatcher:
http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx[^].

However, here is some warning for you:
FileSystemWatcher - Pure Chaos (Part 1 of 2)[^],
FileSystemWatcher - Pure Chaos (Part 2 of 2)[^].

—SA


这篇关于我怎么知道文件夹内容的变化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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