2012-05-10 46 views

回答

6

你問做什麼可以做。例如,病毒掃描程序一直都在使用它。您可以使用Process Monitor輕鬆監控文件活動。您也可以使用FileSystemWatcher Class在C#中進行編程。但是試圖阻止程序打開或試圖阻止程序訪問文件不能在C#中完成。您將需要使用C或C++。您需要創建一個File System Filter Driver。這是一個複雜的事情,但它正是你需要的。引用MSDN:

A file system filter driver intercepts requests targeted at a file system or another file system filter driver. By intercepting the request before it reaches its intended target, the filter driver can extend or replace functionality provided by the original target of the request. Examples of file system filter drivers include anti-virus filters, backup agents, and encryption products.

2

的Sysinternals提供了一個免費的工具,所謂的進程監視器,一個功能是附加到任意的Windows進程(包括.NET應用程序)和捕獲系統調用,包括文件打開,關閉,讀取等。

您可以在Process Monitor Download Page下載。

編輯

當我重讀你的問題,我看到你問攔截,並可能抵消這樣的操作。我相信FileSystemWatcher班將是您最好的選擇,儘管我不認爲它可以單方面取消文件操作 - 您需要建立某種合作機制來指示呼叫方放棄其操作。

相關問題