KILL 刪除文件
RmDir path 刪除目錄或文件夾
如果沒有指定驅
動器,則RmDir會在當前驅動器上刪除目錄或文件夾。如果想要使用RmDir刪除一個含有文件的目錄或文件夾,則會發(fā)生錯誤。只有用Kill語句刪除所有文件后,才能用來RmDir刪除目錄或文件夾
問題補充:照你的意思 看來一句話完成你想要的命令是不行的。必須先列舉里面的的文件夾 然后刪除里面的文件在刪除文件才可以,不過這樣比較麻煩,我剛從別處摘抄了一段代碼 是強行刪除帶有文件的目錄,你自己在套用里面的函數就可以了,希望對你有幫助。。
'VB強行刪除目錄或(VB強行刪除文件)模塊源碼
Public Enum FO_Operation
FO_MOVE = 1
FO_COPY = 2
FO_DELETE = 3
FO_RENAME = 4
End Enum
Public Enum FOFlags
FOF_MULTIDESTFILES = &H1 'Destination specifies multiple files
FOF_SILENT = &H4 'Don't display progress dialog
FOF_RENAMEONCOLLISION = &H8 'Rename if destination already exists
FOF_NOCONFIRMATION = &H10 'Don't prompt user
FOF_WANTMAPPINGHANDLE = &H20 'Fill in hNameMappings member
FOF_ALLOWUNDO = &H40 'Store undo information if possible
FOF_FILESONLY = &H80 'On *.*, don't copy directories
FOF_SIMPLEPROGRESS = &H100 'Don't show name of each file
FOF_NOCONFIRMMKDIR = &H200 'Don't confirm making any needed dirs
End Enum
Public Type SHFILEOPSTRUCT
hwnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAnyOperationsAborted As Long
hNameMappings As Long
lpszProgressTitle As Long ' only used if FOF_SIMPLEPROGRESS
End Type
Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
Private op As SHFILEOPSTRUCT