In my application I'm trying to rename the folder, but if the folder is opened in Windows Explorer I get an IOException
. How can I identify whether folder is opened in Windows Explorer in C#?
catch the IOException?
As others have said, just try to do what you want, catch the exception if it happens and take appropriate action, whatever that is in your context.
You don't really have much choice as I see it, consider:
bool iHaveAccess = CheckAccess(folder);
if (iHaveAccess)
{
RenameFolder(folder,newFolderName);
}
what happens if between CheckAccess succeeding and calling RenameFolder something else locks the folder? Whatcha gonna do then?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With