FileRecycle
删除文件或目录到回收站.
FileRecycle ( "source" )
参数
source
|
目标文件或目录路径. (支持通配符 - 见备注).
|
返回值
成功:
|
返回 1.
|
失败:
|
返回 0 (文件正在使用或不存在).
|
备注
通配符约定: 见 FileFindFirstFile 函数说明.
若要删除目录, 则路径结尾不需要反斜杠.
函数示例
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
Example()
Func Example()
; Create a constant variable in Local scope of the filepath that will be read/written to.
Local Const $sFilePath = _WinAPI_GetTempFileName(@TempDir)
; Create a temporary file to read data from.
If Not FileWrite($sFilePath, "This is an example of using FileRecycle.") Then
MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst writing the temporary file.")
Return False
EndIf
; Display the contents of the file passing the filepath to FileRead instead of a handle returned by FileOpen.
MsgBox($MB_SYSTEMMODAL, "", "Contents of the file:" & @CRLF & FileRead($sFilePath))
; Delete the temporary file by sending to the recycle bin.
Local $iRecycle = FileRecycle($sFilePath)
; Display a message of whether the file was deleted and open the recycle bin if successful.
If $iRecycle Then
MsgBox($MB_SYSTEMMODAL, "", "The file was successfuly deleted.")
; Open the recycle bin by using the following CLSID.
ShellExecute("::{645FF040-5081-101B-9F08-00AA002F954E}")
Else
MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst deleting the file.")
EndIf
EndFunc ;==>Example
----------------------------------------
该函数可以通过命令 exect 调用
参见:
FileDelete, FileRecycleEmpty, DirRemove, FileMove
exect=FileRecycle('D:\*.tmp') ;; 移动到回收站所有文件从.dmp扩展名从磁盘的根目录D:\
exect=FileRecycle('C:\Test\test.txt') ;; 将文件test.txt移动到回收站
exect=FileRecycle('%P%N') ;; 将光标下的文件移动到回收站
© Аверин Андрей для Total Commander Image Averin-And@yandex.ru
|