?
Solved

IIS 7 Locking a PDF file

Posted on 2011-09-08
2
Medium Priority
?
677 Views
Last Modified: 2012-05-12
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.

Cheers.
0
Comment
Question by:dthansen
  • 2
2 Comments
 
LVL 5

Accepted Solution

by:
NKOWA earned 2000 total points
ID: 36503920
Probable Error:
File is open, because, in code behind e-mail attached a file (OPEN), and file didn't close prior to deletion.

Example:
Dim fs as new System.io.FileStream(...)
...read bytes & attach to email
' CALL CLOSE & DISPOSE IF .NET 2.0 +
fs.close
fs.dispose
' THEN
System.IO.File.Delete(..)
0
 
LVL 5

Expert Comment

by:NKOWA
ID: 36503928
Note:
You may also have to recycle you app pool or reboot server in order for the changes to take effect.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
This tutorial will walk an individual through the steps necessary to enable the VMware\Hyper-V licensed feature of Backup Exec 2012. In addition, how to add a VMware server and configure a backup job. The first step is to acquire the necessary licen…
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
Suggested Courses

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question