0

I am using Cefsharp's DownloadHandler to implement a download functionality in WinForms. I am able to cancel the downloading file using callback.Cancel() method in OnDownloadUpdated() method. The problem is that the partially downloaded file is not deleted. I am storing the downloaded files in the "Downloads" folder.

Massimiliano Kraus
  • 3,638
  • 5
  • 27
  • 47

1 Answers1

1

You can just remove the file by yourself after canceling the download. One of the parameters in the OnDownloadUpdated method is downloadItem which contains the full path of the file.

Something like this:

System.IO.File.Delete(downloadItem.FullPath);
Timo Salomäki
  • 7,099
  • 3
  • 25
  • 40
  • if i use System.IO.File.Delete(downloadItem.FullPath), application gets struck. Even i tried deleting file using threads, but file be deleted only after closing the application. Also application has to be closed forcefully using task manager. – Sachin Sajjangandla Aug 22 '17 at 06:17
  • @SachinSajjangandla The OS probably still has a handle on the file. – TEK Aug 22 '17 at 13:23