2013-08-23 81 views

回答

0

只需創建一個處理FormClosing事件並將代碼放在那裏以刪除文件的函數。

Sub frmMain_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing 
+0

很容易,謝謝你 – BSanders

+0

@BSanders只是要小心,本次活動將只有當它們關閉使用解僱X按鈕或通過您提供的按鈕。如果他們使用任務管理器,或他們的計算機崩潰等,臨時目錄將不會被清除。 – JMK

-1

我使用它來刪除我的所有掃描日誌後,我收我的應用VB工作室

Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing 

    Dim s As String = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) 

    Dim c As String = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) 

    If My.Computer.FileSystem.FileExists(s & "/jrt.txt") Then 
     My.Computer.FileSystem.DeleteFile(s & "/jrt.txt") 
    End If 

    If My.Computer.FileSystem.FileExists(s & "/Rkill.txt") Then 
     My.Computer.FileSystem.DeleteFile(s & "/Rkill.txt") 
    End If 

    If My.Computer.FileSystem.FileExists(c & "/Documents/cc*.reg") Then 
     My.Computer.FileSystem.DeleteFile(c & "/Documents/cc*.reg") 
    End If 

    If My.Computer.FileSystem.DirectoryExists("c:/AdwCleaner") Then 
     My.Computer.FileSystem.DeleteDirectory("C:/AdwCleaner", FileIO.UIOption.AllDialogs, FileIO.RecycleOption.DeletePermanently) 
    End If 
End Sub 
相關問題