|
-
Sep 9th, 2004, 06:26 AM
#1
Thread Starter
Addicted Member
I need to read a Text file thats in use.
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?
-
Sep 9th, 2004, 09:32 AM
#2
Addicted Member
What are you currently using to read the file?
I have had much success with the System.IO.Streamreader in situations like this.
-
Sep 9th, 2004, 10:25 AM
#3
Thread Starter
Addicted Member
File: Status.aspx?session=3000
VB Code:
<%
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()
%>
-
Sep 9th, 2004, 10:30 AM
#4
Addicted Member
Try:
Code:
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
-
Sep 9th, 2004, 10:38 AM
#5
Thread Starter
Addicted Member
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.
-
Sep 9th, 2004, 10:45 AM
#6
Addicted Member
Have you given the ASPNET client and IUSR account read access to file? It could be a hidden permissions issue.
-
Sep 9th, 2004, 10:46 AM
#7
Retired VBF Adm1nistrator
Try this
VB Code:
FileOpen(intFileNumber, "C:\Program Files\EA GAMES\MOHAA\mainta\qconsole.log", OpenMode.Input, OpenAccess.Read, OpenShare.Shared)
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Sep 9th, 2004, 10:53 AM
#8
Thread Starter
Addicted Member
Yes the permissions are correct.
And what class is Openfile under i can't find it???
-
Sep 9th, 2004, 11:00 AM
#9
Retired VBF Adm1nistrator
Sorry you need to ensure you're importing from the System.IO namespace
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Sep 9th, 2004, 11:07 AM
#10
Thread Starter
Addicted Member
BC30456: 'Openfile' is not a member of 'IO'.
Last edited by DigitalMyth; Sep 9th, 2004 at 11:12 AM.
-
Sep 9th, 2004, 12:16 PM
#11
Addicted Member
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
-
Sep 9th, 2004, 12:43 PM
#12
Thread Starter
Addicted Member
Oooopppsss. Sorry, I didn't see ya mistake.
Thanks it working great now.
DigitalMyth
VB Code:
<%
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)
%>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|