Solved

IIS 7 Locking a PDF file

Posted on 2011-09-08
2
656 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

OfficeMate Freezes on login or does not load after login credentials are input.
This article explains how to install and use the NTBackup utility that comes with Windows Server.
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…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

717 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