Try
'code to write the file
Catch ex as IOException
'this will happen if there is a lock on the file or if the file cannot be written for some other reason check the 'ex' variable for more info
End Try
Try
'code to write the file
Catch exIO as IOException
'this will happen if there is a lock on the file or if the file cannot be written for some other reason check the 'exIO' variable for more info
Catch ex As Exception
'this will happen if there's a problem that's not an IOException and when you use multiple catch statements, always put this one last (as a fail safe)
End Try