【已解决】FileDelete()如何删除多个文件?
本帖最后由 zjw767676 于 2011-3-28 23:35 编辑FileDelete("路径")
FileDelete("d:\1.txt, 2.txt")这个不行
请教!!!!!! FileDelete("d:\1.txt")
FileDelete("d:\2.txt")
Run(@ComSpec & " /c " & 'del /q D:\1\*.*', "", @SW_HIDE)
或者_filedelete(@ScriptDir&"\backup",'*.jpg',0)
ShellExecute(@ScriptDir&"\backup")
Func _filedelete($path, $ext = '*.*', $flag = 0);_filedelete(路径,[[文件类型],0=不包括子目录,1=包括子目录(当包括子目录时只能用*.*)])
Local $reulst,$abc
If StringRight($path, 1) <> "\" Then $path = $path & "\"
If $flag = 0 Then
$reulst = FileDelete($path&$ext)
Return $reulst
ElseIf $flag = 1 And $ext = '*.*' Then
$search = FileFindFirstFile($path&$ext)
If $search = -1 Then
Return SetError(2)
EndIf
While 1
$file = FileFindNextFile($search)
If @error Then ExitLoop
$abc&=$path&$file&"|"
If FileGetAttrib($path&$file)='D' Then
DirRemove($path&$file,1)
Else
FileDelete($path&$file)
EndIf
WEnd
FileClose($search)
EndIf
EndFunc ;==>_filedelete
感谢楼上两位的热心解答!!!!!!!!!!!! FileDelete支持通配符,可以直接FileDelete("d:\*.txt")
页:
[1]