Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Reading the content of a file being used by another process
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
Reading the content of a file being used by another process
Divers
Thread ID:
00972963
Message ID:
00972963
Vues:
55
Hello UT,

I have a function to read the content of a file (a log file) but the file is currently opened by another process... so I get the exception
"The process cannot access the file because it is being used by another process"

Is there a way to read the file content even if it is being used? (I can open the file with Notepad!)

here's the code I use
        Dim objFileStream As FileStream
        Dim objStreamReader As StreamReader

        Try
            objFileStream = New FileStream(strPath, FileMode.Open, FileAccess.Read)

            objStreamReader = New StreamReader(objFileStream)

            Return objStreamReader.ReadToEnd

        Catch ex As Exception
            Throw
        Finally
            If Not objStreamReader Is Nothing Then
                objStreamReader.Close()
            End If
            If Not objFileStream Is Nothing Then
                objFileStream.Close()
            End If
        End Try
Thanks in advance,
Alex
Alexandre Boudreault-Ferland
Chief Technology Officer
AZUR Technologies
http://www.xicommunity.ca
http://www.xiazur.com
http://endfunction.blogspot.com
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform