Windows Dev Center

The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

FileSystemInfo.Extension Property


Gets the string representing the extension part of the file.

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

public string Extension { get; }

Property Value

Type: System.String

A string containing the FileSystemInfo extension.

The Extension property returns the FileSystemInfo extension, including the period (.). For example, for a file c:\NewFile.txt, this property returns ".txt".

The following table lists examples of other typical or related I/O tasks.

To do this...

See the example in this topic...

Create a text file.

How to: Write Text to a File

Write to a text file.

How to: Write Text to a File

Read from a text file.

How to: Read Text from a File

Retrieve the fully qualified path of a file.


Retrieve only the file name a path.


Retrieve only the directory name from a path.


Change the extension of a file.


Universal Windows Platform
Available since 10
.NET Framework
Available since 1.1
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Return to top
© 2015 Microsoft