I am writing an application in Visual Basic .NET 2003, and am having trouble with the filter for the OpenFileDialog. When I run the app and run the form to bring up the OpenFileDialog, it will not show any files with a *.htm or *.html. But, if I choose the "All Files", it shows everything. How come, if I choose the "HTML Pages" filter, it does not work? Here is my code snippet:
Private Sub btnOpenFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpenFile.Click
' Declare OpenFileDialog object
Dim objOpenFileDialog As New OpenFileDialog
' Set the OpenFileDialog properties
.Filter = "HTML Pages (*.htm; *.html) | *.htm; *.html | All files (*.*) | *.*"
.FilterIndex = 1
.InitialDirectory = "C:\"
.Title = "Open Webpage"
' Show the dialog
If objOpenFileDialog.ShowDialog = DialogResult.OK Then
' If the Open button was clicked, then load the file name selected
txtOpenFile.Text = objOpenFileDialog.FileName
objOpenFileDialog = Nothing