Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
WCrihfield
in reply to: kwilson_design

This is a block of code I have in pretty much all of my export code routines.  You can switch it over to using MessageBox.Show if you want, but if you do, then also replace 'MsgBoxResult' Type with 'DialogResult' Type, because they return different types of values.  Those vbYes & vbNo constants were originally designed for use with the MsgBox, hence their Type being MsgBoxResult, but it is a good idea to use the proper Type objects, when possible, in production related tools.

If System.IO.File.Exists(sFullFileName) = True Then
	Dim oAns As MsgBoxResult = MsgBox("The following file already exists." & vbCrLf & _
	sFullFileName & vbCrLf & "Do you want to overwrite it?", _
	vbYesNo + vbQuestion + vbDefaultButton2, "FILE ALREADY EXISTS")
	If oAns = MsgBoxResult.No Then Exit Sub
End If

If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) :thumbs_up:.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)