Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

  • *Experts*
Posted

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?

"Being grown up isn't half as fun as growing up

These are the best days of our lives"

-The Ataris, In This Diary

Posted

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

  • *Experts*
Posted

What is the service creating the log file? Is it something you have

written and can modify?

"Being grown up isn't half as fun as growing up

These are the best days of our lives"

-The Ataris, In This Diary

Posted

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?

  • *Experts*
Posted

I do not know the solution... maybe someone else can help you

from here.

"Being grown up isn't half as fun as growing up

These are the best days of our lives"

-The Ataris, In This Diary

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...