有没有方法来验证文件是否已打开?我唯一能想到的是Try / Catch,看看我是否可以捕获文件打开异常,但我发现如果文件打开,我可以使用一个方法返回true / false.
@H_502_8@目前在名为Wallet的类下使用System.IO和以下代码.
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
任何指针将不胜感激!谢谢!!