Files icon indicating copy to clipboard operation
Files copied to clipboard

Alert user trying to delete an open file.

Open Henboy10 opened this issue 7 years ago • 4 comments

When trying to delete a file that is open in another program, it gives me an error instead of giving me a warning simply telling me why it failed.

Henboy10 avatar Aug 15 '19 01:08 Henboy10

I can fix this issue.

jgkumaran avatar May 26 '20 12:05 jgkumaran

This occurs because Files UWP tries to delete the file and when it fails, it shows the exception message in a ContentDialog. While we could simply change the message, it will still show the confirmation dialog before deleting if that is enabled. A simple way to check if a file in use is to read it in a stream. If the file can't be read we could assume that the file is open.

jgkumaran avatar May 26 '20 13:05 jgkumaran

@Jaiganeshkumaran Why not just handle the exception thrown when the file is in use?

lukeblevins avatar May 26 '20 15:05 lukeblevins

@Jaiganeshkumaran Why not just handle the exception thrown when the file is in use?

It depends on what you mean by open. Some apps like notepad and the photos app don't lock their file so you can successfully delete those even if it is open. For now I am just going to handle the thrown exception.

jgkumaran avatar May 27 '20 02:05 jgkumaran