FileSystemInfo.Extension Property


Gets the string representing the extension part of the file.

 property System::String ^ Extension { System::String ^ get(); };
public string Extension { get; }
member this.Extension : string
Public ReadOnly Property Extension As String

Property Value


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. GetFullPath
Retrieve only the file name a path. GetFileNameWithoutExtension
Retrieve only the directory name from a path. GetDirectoryName
Change the extension of a file. ChangeExtension

Applies to

See also