I need to read this file that is in use. How do i do it?Quote:
The process can not access the file 'C:\Program Files\EA GAMES\MOHAA\mainta\qconsole.log' because it is being used by another process.
Printable View
I need to read this file that is in use. How do i do it?Quote:
The process can not access the file 'C:\Program Files\EA GAMES\MOHAA\mainta\qconsole.log' because it is being used by another process.
What are you currently using to read the file?
I have had much success with the System.IO.Streamreader in situations like this.
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() %>
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
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.
Have you given the ASPNET client and IUSR account read access to file? It could be a hidden permissions issue.
Try this
VB Code:
FileOpen(intFileNumber, "C:\Program Files\EA GAMES\MOHAA\mainta\qconsole.log", OpenMode.Input, OpenAccess.Read, OpenShare.Shared)
Yes the permissions are correct.
And what class is Openfile under i can't find it???
Sorry you need to ensure you're importing from the System.IO namespace
BC30456: 'Openfile' is not a member of 'IO'.
Its FileOpen not OpenFile, so I imagine you are having a syntax errorQuote:
Originally posted by DigitalMyth
BC30456: 'Openfile' is not a member of 'IO'.
Jamie's code worked fine for me, I didn't need to import the system.io class for make it work
Oooopppsss. Sorry, :blush: :blush: 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) %>