Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    [VB.NET] Xml che resta aperto ....

    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

  2. #2
    Risolto dando un Return non chiudevo l' xml ...


Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.