Web Server CleanUp Question

Posted on 2012-03-23
Last Modified: 2012-03-26
This may sound like the dumbest question...but I'm NEW to Web Developement and

I've recently begun creating PDF using iTextSharp and if I write to the server and then use Window.Open to display it after the user does what ever they want with it (save, print, etc.) how do I get rid of it on the server so these files don't keep building up?

I tried to display the PDF using Window.Open and then delete the file on page unload but it appears that it deletes it before displaying it, so how do I know when the user is done with the file so I can remove it from the server?


If I create the file using can I open the file automatically instead of displaying the dialog box that gives the user the option to Open, Save or Cancel?  I wouldn't mind using Response.Write if I could automatically open the file on completion.

Question by:smithmrk
  • 2
  • 2

Accepted Solution

gery128 earned 500 total points
ID: 37757058
You can do one thing, once your user request for a file, before generating the file you should loop through the directory (where you save your file) and delete all files using IO namespace. So after that you generate one file which will be deleted on subsequent request from the users. That will make sure you will have only one file at a time on server.

Or if you want directly transfer file to response it can be done (assuming the user has Adobe Reader or any other PDF reader plugin installed on browser) by adding special lines to headers:
see this links:

Author Comment

ID: 37757428
Your first link (Stackoverflow) doesn't work...but let me review the other one and I'll get back to you.


Expert Comment

ID: 37759061

Author Closing Comment

ID: 37767611
Not sure which way I'm going to go, but thanks for the advice!


Featured Post

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
In a recent question ( here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

773 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