IIS 7 Locking a PDF file

Server:  Windows 2008 R2 with IIS 7

This server contains a .NET web page and performs the following actions in one of it's pages:

1. Create a PDF file.
2. Email it to the a specific address
3. Delete the PDF file.

During this process, we receive the following error:

The process cannot access the file 'C:\inetpub\wwwroot\admin\output\Invoice-100127-20110908.pdf' because it is being used by another process.

It is failing on STEP 3 because the PDF is created and the email is being sent.

We are currently interested in finding out if there is a setting within IIS that can be changed to alleviate this, or any other solution to this issue whether it be in IIS or the code-behind on the page.

Any assistance would be greatly appreciated.

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Probable Error:
File is open, because, in code behind e-mail attached a file (OPEN), and file didn't close prior to deletion.

Dim fs as new System.io.FileStream(...)
...read bytes & attach to email

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
You may also have to recycle you app pool or reboot server in order for the changes to take effect.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft IIS Web Server

From novice to tech pro — start learning today.