C# Path HasExtension
Description
Path HasExtension
Determines whether a path includes
a file name extension.
Syntax
Path.HasExtension
has the following syntax.
public static bool HasExtension(
string path
)
Parameters
Path.HasExtension
has the following parameters.
path
- The path to search for an extension.
Returns
Path.HasExtension
method returns 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.
Example
The following code example demonstrates the use of the HasExtension method.
//from w w w . j ava2 s. c o m
using System;
using System.IO;
public class MainClass
{
public static void Main(String[] argv)
{
string fileName1 = "myfile.ext";
bool result;
result = Path.HasExtension(fileName1);
Console.WriteLine(result);
}
}
The code above generates the following result.