R
Robinson
Hi,
I was just playing around with my log files and tried to open a log file
programmatically that was considered "in use" (I got an in-use exception).
The file is being used by my debug writer and I wanted to read lines from
the file on one of my forms. It's a simple text file by the way. Now
obviously the exception I get from the code trying to open the file for
reading looks like this:
The process cannot access the file 'C:\Documents and
Settings\mymachine\Application Data\mycomapny\myproduct\log.txt' because it
is being used by another process.
What I don't understand is that I can double click the file and have it open
up in notepad.exe. I don't get an "in use" exception from Explorer, so what
is notepad.exe doing that I cannot being able to open the file? I notice
that you can File.Copy the file while it's in-use and this strikes me as one
way I could get to read a file already in use by the system (copy and then
open and read the copy). Can anyone shed any light on Windows inner
workings in this respect?
Thanks,
Robin
I was just playing around with my log files and tried to open a log file
programmatically that was considered "in use" (I got an in-use exception).
The file is being used by my debug writer and I wanted to read lines from
the file on one of my forms. It's a simple text file by the way. Now
obviously the exception I get from the code trying to open the file for
reading looks like this:
The process cannot access the file 'C:\Documents and
Settings\mymachine\Application Data\mycomapny\myproduct\log.txt' because it
is being used by another process.
What I don't understand is that I can double click the file and have it open
up in notepad.exe. I don't get an "in use" exception from Explorer, so what
is notepad.exe doing that I cannot being able to open the file? I notice
that you can File.Copy the file while it's in-use and this strikes me as one
way I could get to read a file already in use by the system (copy and then
open and read the copy). Can anyone shed any light on Windows inner
workings in this respect?
Thanks,
Robin