B
BenSimmons
Hi i'm creating a program that reads various log files from another
program (Find-a-Drug DC project).
The problem is, when I read some of the logs I get the error
This process cannot access the file"C:\...." because it
is being used by another process
Well I know that as it's the log files for a constantly running DC
program.
The code below is what I'm using.
Public Shared Function ReadWholeFile(ByVal
FilePath As String)
Dim st As String
Try
' Create an instance of StreamReader to read from a file.
Dim sr As StreamReader = New
StreamReader(FilePath)
st = sr.ReadToEnd
sr.Close()
Catch E As Exception
' Let the user know what went wrong.
MessageBox.Show(E.Message.Trim, "The file could
not be read:")
End Try
Return (st)
End Function
The log files are plain text files by the way.
I know the code works when the program is not running.
Now how do I read the file when it is 'in use'
I know it must be posible as you can open it in notepad no problem and
a monitoring tool written in Delphi4 can read it.
How do I do it in VB.Net 2K3?
thanks (relatively new to VB.NET, I've mainly use VBA in Excel)
program (Find-a-Drug DC project).
The problem is, when I read some of the logs I get the error
This process cannot access the file"C:\...." because it
is being used by another process
Well I know that as it's the log files for a constantly running DC
program.
The code below is what I'm using.
Public Shared Function ReadWholeFile(ByVal
FilePath As String)
Dim st As String
Try
' Create an instance of StreamReader to read from a file.
Dim sr As StreamReader = New
StreamReader(FilePath)
st = sr.ReadToEnd
sr.Close()
Catch E As Exception
' Let the user know what went wrong.
MessageBox.Show(E.Message.Trim, "The file could
not be read:")
End Try
Return (st)
End Function
The log files are plain text files by the way.
I know the code works when the program is not running.
Now how do I read the file when it is 'in use'
I know it must be posible as you can open it in notepad no problem and
a monitoring tool written in Delphi4 can read it.
How do I do it in VB.Net 2K3?
thanks (relatively new to VB.NET, I've mainly use VBA in Excel)