CIao io leggo diverse volte, tramite un metodo pubblico di una classe, un file xml che contiene i miei users e i loro privilegi.
Quando la classe legge per la seconda volta il file, mi dice che il fiel è già in uso da un altro processo ...
Ma io eseguo sia il close che il flush ...
codice:
Public Function isAdmin() As Boolean
Dim DS As New DataSet
Dim DT As New DataTable
Dim xmlFileName As String = "../File/user.xml"
Dim fsReadXml As New System.IO.FileStream _
(xmlFileName, System.IO.FileMode.Open)
DS.ReadXml(fsReadXml)
For Each row As DataRow In DS.Tables(0).Rows
If row("name").ToString = Environment.UserName Then
If row("type").ToString = "Admin" Then
Return True
ElseIf row("type").ToString = "Normal" Then
Return False
Else
MessageBox.Show("This user is not able to view statistics.", "User Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Application.Exit()
End If
End If
Next
fsReadXml.Close()
fsReadXml.Flush()
fsReadXml = Nothing
Return False
End Function