FileExists

首页  后退  前进

FileExists
down2

FileExists

检查文件或目录是否存在.

 

FileExists ( "path" )

参数

Path

文件或目录的路径.

返回值

成功:

返回 1.

失败:

返回 0, 指定路径/文件不存在.

备注

如果指定软驱未插入磁盘, 则本函数返回 0.

 

函数示例

#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)
    Local $iFileExists = FileExists($sFilePath)
    ; Display a message of whether the file exists or not.
    If $iFileExists Then
        MsgBox($MB_SYSTEMMODAL, "", "The file exists." & @CRLF & "FileExist returned: " & $iFileExists)
    Else
        MsgBox($MB_SYSTEMMODAL, "", "The file doesn't exist." & @CRLF & "FileExist returned: " & $iFileExists)
    EndIf
    ; Delete the temporary file.
    FileDelete($sFilePath)
EndFunc   ;==>Example

----------------------------------------

 

该函数可以通过命令 exect 调用

参见:

FileGetAttrib, DriveStatus

例子
copy

exect=$var_i=FileExists('C:\Test\test.txt')||_ViewValues('$var_i') ;; 返回1  - 如果文件test.txt存在和0,如果无

 

exect=$var_i=(StringInStr(FileGetAttrib('%P%N'),'D')~~And~~FileExists('%P%N'))?1:0||_ViewValues($var_i) ;; 检查:返回1,如果在光标文件夹下,0  - 如果文件

up2

tcimage © Аверин Андрей для Total Commander Image Averin-And@yandex.ru