Share via


HasExtension Method

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Determines whether a path includes a file name extension.

Namespace:  System.IO
Assembly:  System.IO (in System.IO.dll)

Syntax

'Declaration
Public Shared Function HasExtension ( _
    path As String _
) As Boolean
public static bool HasExtension(
    string path
)
public:
static bool HasExtension(
    String^ path
)
static member HasExtension : 
        path:string -> bool 
public static function HasExtension(
    path : String
) : boolean

Parameters

Return Value

Type: System. . :: . .Boolean
true if the characters that follow the last directory separator (\\ or /) or volume separator (:) in the path include a period (.) followed by one or more characters; otherwise, false.

Exceptions

Exception Condition
ArgumentException

path contains one or more of the invalid characters defined in GetInvalidPathChars.

Remarks

Starting from the end of path, this method searches for a period (.) followed by at least one character. If this pattern is found before a DirectorySeparatorChar character is encountered, this method returns true.

.NET Framework Security

See Also

Reference

Path Class

System.IO Namespace