Delete Pdf in c #

3

How can I delete a PDF file once I close the document? Does anyone know how to do this in C #? Now I have the code that opens the PDF, but I want to close the PDF automatically.

var pdfProcess = System.Diagnostics.Process.Start(ruta);
    
asked by Cesar Ramirez Monroy 29.03.2016 в 01:16
source

1 answer

2

using Process.Exited and using File.Delete , before deleting it, it ends the process:

pdfProcess.Exited += new EventHandler(pdfProcess_Exited);
void pdfProcess_Exited(object sender, EventArgs e)    {  
     pdfProcess.Kill(); //importante terminar el proceso!
     System.IO.File.Delete(ruta);
    }
    
answered by 29.03.2016 в 01:37