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
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?