read file while in use by another program

sp0n9e

New member
Joined
Dec 12, 2003
Messages
3
Im trying to read a log file from a program and insert the events in an easy-to-manage database. I can open the file in notepad, and i can see everything, but when I try to access the file, it gives me an error saying another process is using this file.

I know the process is using the file, and it is being updated...when i stop the program that makes the log file, i can read it fine, so I know there are no apparent errors that might indirectly cause this problem.

SUMMARY:
how do you open a file while in use by another process (only read permission is needed). I can open it in notepad while the process is running, so I know its possible.
 
I believe that error message is a little misleading... it sounds more
like your own process has opened the file and hasnt closed the
stream yet. Do you have any code before the program actually
reads the file that might be accessing the files contents or
properties, or something that writes to that file?
 
the code all works fine, unless service creating the log file is open...

when its open, it gives me an error stating: The process cannot access the file "C:\...\ventrilo_srv.log" because it is being used by another process.

but notepad can still open it...
Ive tried using read-only...but that does not work

here is the (relevant) code anyway:

Code:
        Dim srLog As StreamReader
         Open the file to read.
        srLog = File.OpenText(filePath)
         Read each line in the file into the array
        While srLog.Peek <> -1
            ReDim Preserve strLogLines(index)
            strLogLines(index) = srLog.ReadLine()
            index += 1
        End While
 
What is the service creating the log file? Is it something you have
written and can modify?
 
nope, its a voice communication program called ventrilo...but it should be possible to look at the file, i mean, notepad can do it, why cant my program do it?

would i need a lower level language?
 
Back
Top