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);
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);
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);
}