Returns the extension of the specified path.
[Visual Basic] Public Shared Function GetExtension( _ ByVal path As String _ ) As String [C#] public static string GetExtension( string path ); [C++] public: static String* GetExtension( String* path ); [JScript] public static function GetExtension( path : String ) : String;
The extension of the specified path (including the "."), or Empty.
Exception Type | Condition |
---|---|
ArgumentNullException | path is a null reference (in Visual Basic Nothing). |
ArgumentException | path is empty or contains only whitespaces. |
The extension is obtained by searching backwards within path for the "." character. If "." is matched before Environment.DirectorySeparatorChar, Environment.AltDirectorySeparatorChar, or Environment.VolumeSeparatorChar is encountered, then the "." and the characters following the "." are returned as the result. Otherwise, Empty is returned.
The returned value includes the period (".") character of the extension, such as ".exe" or ".cpp".