File access issue

  • Thread starter Thread starter Jason
  • Start date Start date
J

Jason

I am writing a program that opens a file and writes to it. When I open the
file to read data from it, I have no problems but when I try and write to it
I get an error saying that the file is already in use
(System.IO.IOException: The process cannot access the file
"O:\2006-04-25\2006-04-25.mpg" because it is being used by another
process.). As you can see the file is an mpeg file which are often very
large so I would rather not make a copy of the file to avoid the problem. I
used "Process Explorer" and found that Windows Explorer is locking my mpeg
files any time they are opened and will not release them unless the process
is killed and then started again. In Process Explorer there is an option to
close the handle which fixes the problem. Can anyone tell me how to add
this into my program so that if I run into this problem, I can simply close
the handle and try again? Thanks in advance for your help. -Jason
 
Thanks for the reply but I am actually needing to write to the file as I am
patching the header. I need to open it with write access.
 
Back
Top