FileSystemInfo.Extension 属性

定义

获取表示文件扩展名部分的字符串。Gets the string representing the extension part of the file.

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

属性值

包含 FileSystemInfo 扩展名的字符串。A string containing the FileSystemInfo extension.

注解

Extension 属性FileSystemInfo返回扩展, 包括句点 (.)。The Extension property returns the FileSystemInfo extension, including the period (.). 例如, 对于 c:\NewFile.txt 文件, 此属性将返回 ".txt"。For example, for a file c:\NewFile.txt, this property returns ".txt".

下表列出了其他典型或相关 i/o 任务的示例。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

适用于

另请参阅