Vb.net 我可以删除表单关闭时的文件吗?
我有一个基本程序,可以将文件复制到临时目录,提取文件,然后打开文件。我要做的是在appclose上从目录中删除该文件 只需创建一个处理FormClosing事件的函数,并将代码放入其中以删除文件Vb.net 我可以删除表单关闭时的文件吗?,vb.net,visual-studio-2012,Vb.net,Visual Studio 2012,我有一个基本程序,可以将文件复制到临时目录,提取文件,然后打开文件。我要做的是在appclose上从目录中删除该文件 只需创建一个处理FormClosing事件的函数,并将代码放入其中以删除文件 Sub frmMain_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing 关闭我的应用程序vb studio后,
Sub frmMain_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
关闭我的应用程序vb studio后,我使用此选项删除所有扫描日志
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
@b学员请小心,只有当他们使用X按钮或通过您提供的按钮关闭时,才会触发此事件。如果他们使用任务管理器,或他们的计算机崩溃等,临时目录将不会被清除。