I have 2 filters on my dialog: *.m3u and *.wpl. How do I find out what choice the user made?
Printable View
I have 2 filters on my dialog: *.m3u and *.wpl. How do I find out what choice the user made?
You need to check the .FilterIndex property to see which the user choose but they could still have typed in the file with a different acceptable extension.
VB Code:
SaveFileDialog1.FilterIndex
Or just get the right 3 characters returned from the filepath of the dialog...
EDIT*** - uppercase extensions won't work with this code, you have to do myextension = myextension.tolower in order to always make it lowercase in order for it to work, or change your case statements to also evaluate it for the uppercase M3U or WPLVB Code:
Dim MyExtension as String MyExtension = strings.right(ReturnDialogString, 3) 'returns last 3 letters, replace returndialogstring with filepath returned from dialog Select Case MyExtension Case Is = "m3u" MsgBox("m3u") Case Is = "wpl" MsgBox("wpl") Case Else MsgBox("Not A Supported FileType!") Exit Sub End Select
Use IO.Path to manipulate file paths, e.g. IO.Path.GetExtension(mySaveFileDialog.FileName)