Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to delete PDF files after viewing
Message
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
C# 2.0
Divers
Thread ID:
01209270
Message ID:
01210617
Vues:
15
I tend to use a deletion pattern for this where before or after you've generated a PDF you delete the files that exist before a specified timeout period (or simply any files that are not locked currently).

This results in a few temporary files active at any time, but never more than a few that are within the timeout period.

For this to work you need to have control over the PDF filenames generated and use some sort of naming convention so you know which files to delete.

+++ Rick ---


>I'm trying to use the the following code to show pdf or xls file generated by ReportViewer.
>After application closes, temporary files remain in disk.
>
>How to delete PDF files after Adobe Reader is closed ?
>Is the best way to save files passed to external application to temporary directory and delete whole directory if application exits or use filewatcher?
>Any sample how to implement this ?
>
>
void ShowPDF( byte[] bytes ) {
>static int i=0;
>string outputfile = "temp"+(i++).ToString()+".pdf";
>FileStream fs = new FileStream(outputFile, FileMode.Create);
>fs.Write(bytes, 0, bytes.Length);
>fs.Close();
>System.Diagnostics.Process p = new System.Diagnostics.Process();
>p = new System.Diagnostics.Process();
>
>p.StartInfo.FileName = outputFile;
>p.Start();
>}
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform