您可以file.exists(filename)在打开它或尝试捕获块之前进行检查:
If not System.IO.File.Exists(filename) Then
' file does not exist
end if
Run Code Online (Sandbox Code Playgroud)
要么
Try
open ...
Catch ex As Exception
MsgBox(ex.Message) ' not-found error handling goes here
End Try
Run Code Online (Sandbox Code Playgroud)
您可以imports system.io在文件顶部添加要使用的文件File.Exists而不是System.IO.File.Exists。
| 归档时间: |
|
| 查看次数: |
8816 次 |
| 最近记录: |