FileSystemWatcher.OnDeleted(FileSystemEventArgs) 方法

定義

引發 Deleted 事件。

protected:
 void OnDeleted(System::IO::FileSystemEventArgs ^ e);
protected void OnDeleted (System.IO.FileSystemEventArgs e);
member this.OnDeleted : System.IO.FileSystemEventArgs -> unit
Protected Sub OnDeleted (e As FileSystemEventArgs)

參數

e
FileSystemEventArgs

FileSystemEventArgs,其中包含事件資料。

備註

OnDeleted 刪除受監視目錄中的檔案或目錄時, 會呼叫 。

某些常見的情況,例如複製或移動檔案或目錄,不會直接對應至事件,但這些發生次數會導致引發事件。 當您複製檔案或目錄時,如果正在監看該目錄,系統會在複製檔案的目錄中引發 Created 事件。 如果您複製的目錄正由另一個 實例 FileSystemWatcher監看,則不會引發任何事件。 例如,您會建立 兩個 實例 FileSystemWatcher。 FileSystemWatcher1 設定為 watch “C:\My Documents”,而 FileSystemWatcher2 設定為 watch “C:\Your Documents”。 如果您將檔案從 「My Documents」 複製到 “Your Documents”, Created FileSystemWatcher2 將會引發事件,但 FileSystemWatcher1 不會引發任何事件。 不同於複製,移動檔案或目錄會引發兩個事件。 從上一個範例中,如果您將檔案從 「My Documents」 移至 「Your Documents」, Created 則 FileSystemWatcher2 會引發事件,而 Deleted FileSystemWatcher1 會引發事件。

引發事件會透過委派叫用此事件處理常式。 如需詳細資訊,請參閱 處理和引發事件

給繼承者的注意事項

OnDeleted(FileSystemEventArgs) 衍生類別中覆寫時,請務必呼叫基類的 OnDeleted(FileSystemEventArgs) 方法。

適用於

另請參閱