This documentation is archived and is not being maintained.

FileSystemInfo.Extension Property

Gets the string representing the extension part of the file.

[Visual Basic]
Public ReadOnly Property Extension As String
[C#]
public string Extension {get;}
[C++]
public: __property String* get_Extension();
[JScript]
public function get Extension() : String;

Property Value

A string containing the FileSystemInfo extension.

Remarks

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. Writing Text to a File
Write to a text file. Writing Text to a File
Read from a text file. Reading 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

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

FileSystemInfo Class | FileSystemInfo Members | System.IO Namespace | Working with I/O | Reading Text from a File | Writing Text to a File

Show: