sp0n9e Posted December 15, 2003 Posted December 15, 2003 I'm 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. Quote
*Experts* Bucky Posted December 15, 2003 *Experts* Posted December 15, 2003 I believe that error message is a little misleading... it sounds more like your own process has opened the file and hasn't closed the stream yet. Do you have any code before the program actually reads the file that might be accessing the file's contents or properties, or something that writes to that file? Quote "Being grown up isn't half as fun as growing up These are the best days of our lives" -The Ataris, In This Diary
sp0n9e Posted December 15, 2003 Author Posted December 15, 2003 the code all works fine, unless service creating the log file is open... when it's 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... I've tried using read-only...but that does not work here is the (relevant) code anyway: 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 Quote
*Experts* Bucky Posted December 15, 2003 *Experts* Posted December 15, 2003 What is the service creating the log file? Is it something you have written and can modify? Quote "Being grown up isn't half as fun as growing up These are the best days of our lives" -The Ataris, In This Diary
sp0n9e Posted December 15, 2003 Author Posted December 15, 2003 nope, it's a voice communication program called ventrilo...but it should be possible to look at the file, i mean, notepad can do it, why can't my program do it? would i need a lower level language? Quote
*Experts* Bucky Posted December 15, 2003 *Experts* Posted December 15, 2003 I do not know the solution... maybe someone else can help you from here. Quote "Being grown up isn't half as fun as growing up These are the best days of our lives" -The Ataris, In This Diary
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.