ファイルが開いていることを確認する方法はありますか? 私が考えることができる唯一のことはTry/Catch
、ファイルを開く例外をキャッチできるかどうかを確認することですが、ファイルが開いている場合に true/false を返すメソッドが利用できると考えました。
現在System.IO
、という名前のクラスの下で次のコードを使用していますWallet
。
Private holdPath As String = "defaultLog.txt"
Private _file As New FileStream(holdPath, FileMode.OpenOrCreate, FileAccess.ReadWrite)
Private file As New StreamWriter(_file)
Public Function Check(ByVal CheckNumber As Integer, ByVal CheckAmount As Decimal) As Decimal
Try
file.WriteLine("testing")
file.Close()
Catch e As IOException
'Note sure if this is the proper way.
End Try
Return 0D
End Function
任意のポインタをいただければ幸いです!ありがとうございました!!