vb.net 如何在VB.Net中过滤打开文件对话框
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18579061/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to filter open file dialog in VB.Net
提问by user2618553
How do I filter file types in open - save file dialog with these types? I want to list all files EXCLUDING*JAR and *JAVA example I found on google:
如何在打开 - 保存这些类型的文件对话框中过滤文件类型?我想列出我在谷歌上找到的所有文件EXCLUDING*JAR 和 *JAVA 示例:
Using O As New OpenFileDialog With {.Filter = "(Image Files)|*.jpg;*.png;*.bmp;*.gif;*.ico|Jpg, | *.jpg|Png, | *.png|Bmp, | *.bmp|Gif, | *.gif|Ico | *.ico", .Multiselect = False, .Title = "Select Image"}
If O.ShowDialog = 1 Then
TextBox1.Text = O.FileName
End If
End Using
回答by SMHasnain
hi you can try this code.
你好,你可以试试这个代码。
openFD.InitialDirectory = "C:\"
openFD.Title = "Open a Text File"
openFD.Filter = "Text Files|*.txt"
openFD.ShowDialog()
feel free to contact if get problem.
如果有问题,请随时联系。
Regards.
问候。
回答by user613326
There no excluding option in those filters. You might add code later not to process something if its file type ends with xxxxx (whatver you want to exclude).
这些过滤器中没有排除选项。如果文件类型以 xxxxx 结尾(无论您想排除什么),您可以稍后添加代码以不处理它。