'********************************************************* '* 名称:FileExists%(filename$) '* 功能:此函数用于判断文件是否存在 '* 用法:FileExists%('文件名称') '* 文件不存在返回 0 '********************************************************* Function FileExists%(filename$) Dim F%
On Error Resume Next
F% = FreeFile Open filename$ For Input As #F% Close #F%
FileExists% = Not (Err <> 0) End Function
if dir(App.Path + "test.txt")<>"" then '存在文件 end if或者使用 Dim fso As New FileSystemObjectIf fso.FileExists(App.Path + "test.txt") Then '存在文件 end if需要在 引用中加入:microsoft scripting runtime
msgbox "存在文件"
endif
'* 名称:FileExists%(filename$)
'* 功能:此函数用于判断文件是否存在
'* 用法:FileExists%('文件名称')
'* 文件不存在返回 0
'*********************************************************
Function FileExists%(filename$)
Dim F%
On Error Resume Next
F% = FreeFile
Open filename$ For Input As #F%
Close #F%
FileExists% = Not (Err <> 0)
End Function
'存在文件
end if或者使用
Dim fso As New FileSystemObjectIf fso.FileExists(App.Path + "test.txt") Then
'存在文件
end if需要在 引用中加入:microsoft scripting runtime