2013-12-17 88 views
1

我正在使用UFT中的api測試通過FTP傳輸文件,如果該文件不存在於本地文件系統上,那麼當我嘗試傳輸它時,一個預期的原始名稱的空文件被創建並通過ftp傳輸。有沒有辦法返回一個錯誤,而不是通過FTP複製一個空白文件?我很樂意使用自定義代碼在複製之前檢查文件的存在性,但如果UFT在文件不存在的情況下會返回一個錯誤會更好。如何使用UFT在本地文件系統上驗證文件

+0

我發現我自己的答案:-)對於Api測試 在工具箱 - >文件 - >文件存在 – user3111710

回答

2

請嘗試這一個希望,這將有助於

Set fileSystemObj = createobject("Scripting.FileSystemObject") 

'要檢查是否存在給定文件'

MyFile = "C:\TestFile.txt" 

If fileSystemObj.FileExists(MyFile) then 

    Msgbox "File is present" & MyFile 

Else 

    Msgbox "File does not present" & MyFile 

End If 

'要檢查是否存在指定的文件夾'

MyFolder = "C:\TestFolder" 

If fileSystemObj.FolderExists(MyFolder) Then 

    Msgbox "Folder is present" & MyFolder 

Else 

    Msgbox "Folder does not present" & MyFolder 

End If 

'要檢查給定的驅動器是否存在'

MyDrive ="D:\" 

If fileSystemObj.DriveExists(MyDrive) then 

    Msgbox "Drive is present" & MyDrive 

Else 

    Msgbox "Drive does not present" & MyDrive 

End If 

Set fileSystemObj = Nothing 
相關問題