webkiwi1
asked on
OpenFileDialog - determine file type
Hello Experts,
VB.NET, Visual Studio 2005
I am using the code provided and would like to determine if the user picks an excel file.
What parameter do I check for .xls?
Thanks
VB.NET, Visual Studio 2005
I am using the code provided and would like to determine if the user picks an excel file.
What parameter do I check for .xls?
Thanks
OpenFileDialog1.Filter = "Text or Microsoft Excel Files (*.txt*; *.xls*)|*.txt; *.xls" ' Shows .txt and .xls files
OpenFileDialog1.FilterIndex = 1
OpenFileDialog1.Title = "Browse to file:"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
VBRocks, that give me the file name without the extension...
sorry. try the second post.
ASKER
oops, our messages crossed.
Solution worked, THANKS!
Solution worked, THANKS!
You could also create a FileInfo instance out of it like this:
If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult .OK Then
Dim fi As New System.IO.FileInfo(OpenFil eDialog1.F ileName)
If fi.Extension.ToUpper = ".XLS" Then
' ...do something with "fi"...
MessageBox.Show(fi.FullNam e, "Excel File Selected")
End If
End If
If OpenFileDialog1.ShowDialog
Dim fi As New System.IO.FileInfo(OpenFil
If fi.Extension.ToUpper = ".XLS" Then
' ...do something with "fi"...
MessageBox.Show(fi.FullNam
End If
End If
If ext = ".txt" OrElse ext = ".xls" Then
End If