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) 方法。

適用於

另請參閱