Solved

IIS 7 Locking a PDF file

Posted on 2011-09-08
2
645 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 500 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
This tutorial will walk an individual through the steps necessary to configure their installation of BackupExec 2012 to use network shared disk space. Verify that the path to the shared storage is valid and that data can be written to that location:…
In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

856 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