.NET Array Dictionary List String Sub ArrayList Cast Class Console Dates DataTable DateTime Enum File For Format If IndexOf Lambda LINQ Nothing Parse Process Property Regex Replace Select Sort Split StringBuilder SubstringFile Extension. A file has an extension. This is optional. It occurs at the end of the file name. With the Path.GetExtension Function we acquire the extension. We then make decisions based on its value. This method has some interesting behavior.Path
Finally: The program shows exactly what the extension is. The period is included at the start of the three-character extension.
VB.NET program that uses Path.GetExtension Imports System.IO Module Module1 Sub Main() ' Input path. Dim p As String = "C:\Users\Sam\Documents\Test.txt" ' Get extension. Dim extension As String = Path.GetExtension(p) ' Display extension. Console.WriteLine(extension) Console.WriteLine(".txt" = extension) End Sub End Module Output .txt TrueWhen using Path.GetExtension, developers may assume the period is not included in the extension string. To compare the extension string, you must use a string literal such as ".txt" with the period prefixing the three letters.Strings