Solved

IIS 7 Locking a PDF file

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article focuses on how to remove password security from multiple PDF files by Adobe Acrobat program. Sometimes it is essential to access the stored data items and to print, edit as well as copy content from Portable Document Format files in abs…
A procedure for exporting installed hotfix details of remote computers using powershell
This tutorial will walk an individual through setting the global and backup job media overwrite and protection periods in Backup Exec 2012. Log onto the Backup Exec Central Administration Server. Examine the services. If all or most of them are stop…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

759 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now