Export (0) Print
Expand All
2 out of 4 rated this helpful - Rate this topic

How to: Determine a File's Extension in Visual Basic 

The My.Computer.FileSystem.GetFiles Method returns the names of files as a read-only collection of strings, which can be parsed with the Split Function (Visual Basic).

To determine a file's extension

  • Retrieve the file path or name of the file and the Split function to determine the extension by supplying the delimiter. This example uses the GetFiles method to return the collection of file names in the directory testDirectory and reports each file's extension.

    For Each foundFile As String In _
        Dim check As String = _
        MsgBox("The file extension is " & check)

See Also

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2014 Microsoft. All rights reserved.