Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Reading the content of a file being used by another process
Message
General information
Forum:
ASP.NET
Category:
Other
Title:
Reading the content of a file being used by another process
Miscellaneous
Thread ID:
00972963
Message ID:
00972963
Views:
54
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
Next
Reply
Map
View

Click here to load this message in the networking platform