Try
' 先建立目录以便用于后续的删除示范。
If Not Directory.Exists("D:\网易") Then
Directory.CreateDirectory(" D:\网易 \Test1")
Directory.CreateDirectory(" D:\网易 \Test2")
Directory.CreateDirectory(" D:\网易 \Test3")
End If
' 删除子目录 Test1。
Directory.Delete(" D:\网易 \Test1", True)
' 删除子目录 Test2。
Dim myDirectoryInfo As New DirectoryInfo(" D:\网易 \Test2")
myDirectoryInfo.Delete(True)
' 将目录 C:\AlexDirDemo 及其以下的文件和子目录全数删除。
Directory.Delete(" D:\网易 ", True)
Catch ex As Exception
MessageBox.Show(ex.Message)
Exit Sub
End Try
' 启动 Windows 资源管理器。
Process.Start("explorer.exe", "D:\")
End Sub
你罗列的这几个函数API,在其后面把路径带进去调用就可以了 已经是很简单了。还要说明什么?Private Declare Function DeleteFile Lib "kernel32" Alias "DeleteFileA" (ByVal lpFileName As String) As Long
Private Sub Form_Load()
DeleteFile "c:\test.txt"
Set fs = CreateObject("Scripting.FileSystemObject")
fs.DeleteFile "c:\test.txt"
fs.deletefolder "c:\test"
Kill "c:\test.txt"
RmDir "c:\test"
End Sub
欢迎分享,转载请注明来源:夏雨云
评论列表(0条)