私はVB.NETに少し慣れていません。開いているファイルが存在しないかどうかを検出する方法があるかどうか疑問に思いました。そうすると、何かが起こります。これは可能であり、「If」ステートメントを使用して可能ですか?
11378 次
1 に答える
6
開く前に確認するために使用file.exists(filename)
するか、try-catchブロックを使用できます。
If not System.IO.File.Exists(filename) Then
' file does not exist
end if
また
Try
open ...
Catch ex As Exception
MsgBox(ex.Message) ' not-found error handling goes here
End Try
の代わりにimports system.io
使用するファイルの先頭に追加できます。File.Exists
System.IO.File.Exists
于 2012-12-08T20:10:10.093 に答える