SaveAs Dialog with a period in the filename does not return extension

半腔热情 提交于 2019-12-24 20:19:31

问题


How do I make sure SaveAs Dialog return a filename with the extension?

For Example:

'Test' (.txt) return 'test.txt'

But:

'Test 1.0' (.txt) return 'Test 1.0' (Should be 'Test 1.0.txt')

Possible solution: I can manually check if there is a '.txt' at the end, but if there are two extension types (.txt, .doc), how do I know which one the user selected?

Thank you!


回答1:


I believe you need to set the .SupportMultiDottedExtensions to True, like so:

Using tDialog As SaveFileDialog = New SaveFileDialog
With tDialog
        .Filter = "Text Files|*.txt"
        .SupportMultiDottedExtensions = True
        .ShowDialog()
        MsgBox(.FileName)
    End With
End Using


来源:https://stackoverflow.com/questions/9593305/saveas-dialog-with-a-period-in-the-filename-does-not-return-extension

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!