Click to See Complete Forum and Search --> : I need to read a Text file thats in use.
DigitalMyth
Sep 9th, 2004, 06:26 AM
The process can not access the file 'C:\Program Files\EA GAMES\MOHAA\mainta\qconsole.log' because it is being used by another process.
I need to read this file that is in use. How do i do it?
rdove
Sep 9th, 2004, 09:32 AM
What are you currently using to read the file?
I have had much success with the System.IO.Streamreader in situations like this.
DigitalMyth
Sep 9th, 2004, 10:25 AM
File: Status.aspx?session=3000
<%
Dim path as String = "C:\Program Files\EA GAMES\MOHAA\mainta\qconsole.log"
Dim fs as filestream
fs = File.OpenRead(path)
Dim b(1024) As Byte
Dim temp As UTF8Encoding = New UTF8Encoding(True)
Do While fs.Read(b, 0, b.Length) > 0
response.write(temp.GetString(b))
Loop
fs.Close()
%>
rdove
Sep 9th, 2004, 10:30 AM
Try:
Dim sr As StreamReader
Dim strText As String
Dim path as String = "C:\Program Files\EA GAMES\MOHAA\mainta\qconsole.log"
Try
sr = New StreamReader(path)
strText = sr.ReadToEnd()
sr.Close()
Catch ex As Exception
Throw
End Try
DigitalMyth
Sep 9th, 2004, 10:38 AM
same error on throw.
i don't understand this because i made a simple VB program to do the same thing can that has no problems.
rdove
Sep 9th, 2004, 10:45 AM
Have you given the ASPNET client and IUSR account read access to file? It could be a hidden permissions issue.
plenderj
Sep 9th, 2004, 10:46 AM
Try this
FileOpen(intFileNumber, "C:\Program Files\EA GAMES\MOHAA\mainta\qconsole.log", OpenMode.Input, OpenAccess.Read, OpenShare.Shared)
DigitalMyth
Sep 9th, 2004, 10:53 AM
Yes the permissions are correct.
And what class is Openfile under i can't find it???
plenderj
Sep 9th, 2004, 11:00 AM
Sorry you need to ensure you're importing from the System.IO namespace
DigitalMyth
Sep 9th, 2004, 11:07 AM
BC30456: 'Openfile' is not a member of 'IO'.
rdove
Sep 9th, 2004, 12:16 PM
Originally posted by DigitalMyth
BC30456: 'Openfile' is not a member of 'IO'.
Its FileOpen not OpenFile, so I imagine you are having a syntax error
Jamie's code worked fine for me, I didn't need to import the system.io class for make it work
DigitalMyth
Sep 9th, 2004, 12:43 PM
Oooopppsss. Sorry, :blush: :blush: I didn't see ya mistake.
Thanks it working great now.
DigitalMyth
<%
FileOpen(1, "C:\Program Files\EA GAMES\MOHAA\mainta\qconsole.log", OpenMode.Input, OpenAccess.Read, OpenShare.Shared)
Do While Not EOF(1)
Dim TextLine as string = LineInput(1)
Response.write(Textline)
Response.Write("<br>")
Loop
Fileclose(1)
%>
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.