A part of my application deletes some folders on a particular directory.
If a folder is deleted, everything is OK. However, sometimes it is not deleted for some reason (e.g. a file of the folder is open) and an error message is generated.
Attachment 94729
I would like my application to catch any error messages and if they appear, OK button should be clicked automatically. I have tried to insert SendKeys.SendWait("{ENTER}") after Catch ex As Exception line, but it did not help.
I would be grateful if anybody could help me.
Code:
Try
My.Computer.FileSystem.DeleteDirectory(subdirDest, _
FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.SendToRecycleBin)
strDeletedFolderd = strDeletedFolderd + subdirDest + vbNewLine
Catch ex As Exception
strErrors = strErrors + subdirDest + vbNewLine
strErrors = strErrors + "Reason: " + ex.ToString + vbNewLine + vbNewLine
End Try
Attachment 94729
I would like my application to catch any error messages and if they appear, OK button should be clicked automatically. I have tried to insert SendKeys.SendWait("{ENTER}") after Catch ex As Exception line, but it did not help.
I would be grateful if anybody could help me.