Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to fabricate a "file in use" scenario. I am programming exception handling for this particular scenario but I am unable to come up with a way to put a file "in use" so other programs are unable to delete or modify it.

Is there a simple way to do this that I'm overlooking?

share|improve this question
up vote 2 down vote accepted

Try to open that file with Excel application. I do not remember what actions exactly it disallows, but deletion for sure.

share|improve this answer
Excel also seems to be particularly aggressive about not allowing other applications to access files it has open. – dsolimano Oct 3 '12 at 1:54
Didn't work unfortunately. – Joe Philllips Oct 3 '12 at 1:56
Then write couple of lines of C/C#/VB code :) – Serge Oct 3 '12 at 2:01
Actually Excel does the trick! – Joe Philllips Oct 3 '12 at 2:02
@dsolimano repost your advice as answer please – Serge Oct 3 '12 at 2:02

Write another program that opens a text file, writes some text to it but does not close the file. That should make sure that it is in use.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.