有没有办法验证文件是否打开?我唯一能想到的是Try/Catch
看看我是否可以捕获文件打开异常,但我认为如果文件打开,可以使用一种方法来返回真/假。
目前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
任何指针将不胜感激!谢谢!!