窗口计时器里面写了这个代码:
Dim fileName As String = "d:\data.txt"
Dim inUse As Boolean = True
Dim fs As system.io.FileStream = Nothing
Try
fs = New system.io.FileStream(fileName, system.io.FileMode.Open, system.io.FileAccess.Read, system.io.FileShare.None)
inUse = False
Catch ex As Exception
Finally
If (fs IsNot Nothing) Then
fs.Close()
End If
End Try
If inUse = True Then
e.Form.Controls("Label1").text = "空闲"
Else
e.Form.Controls("Label1").text = "占用"
End If
窗口上做了个按钮,写入文本得代码:
FileSys.WriteAllText("d:\data.txt", "I Like Foxtable", True)
首次打开窗口得时候显示“空闲”,写入文本一次之后就一直是“占用”状态。怎么回事?