Takeshi-4630 avatar image
0 Votes"
Takeshi-4630 asked Jerryzy edited

Cannot delete file becouse it is used by another process.

Hi all,
I dont understand my problem. In DocumentPage I upload pdf file ->I show it in dataGrid -> after select this dtg row ti create pdf file in some folder and at the same time it show it in webBrowser. After exit applicatin I am trying to delete this file but it shows me en arror mentioned in question title.

my exit function:


 <Application ...


 public partial class App : Application
         void App_Exit(object sender, ExitEventArgs e)
             DocumentPage z = new DocumentPage();
             if (Directory.Exists("temp"))
                 Directory.Delete("temp", true);

... here it shows me that eror message

  1. In same page (DocumentPage) I have button with function ( clear() ) : pdfDokument.Navigate("about:blank");

after click on that button ... application exit and sucessfull delete folder temp with all files inside

SO I dont understand why it is ok with click on that button and when I use this function in app_exit ... it doesnt work

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

0 Answers