FileSystemInfo.FullName 属性

定义

获取目录或文件的完整目录。

C#
public virtual string FullName { get; }

属性值

包含完整目录的字符串。

例外

完全限定路径名称和文件名的长度超出系统定义的最大长度。

调用方没有所要求的权限。

示例

以下示例演示 了 FullName 属性。 此代码示例是为 FileSystemInfo 类提供的一个更大示例的一部分。

C#
static void DisplayFileSystemInfoAttributes(FileSystemInfo fsi)
{
    //  Assume that this entry is a file.
    string entryType = "File";

    // Determine if entry is really a directory
    if ((fsi.Attributes & FileAttributes.Directory) == FileAttributes.Directory )
    {
        entryType = "Directory";
    }
    //  Show this entry's type, name, and creation date.
    Console.WriteLine("{0} entry {1} was created on {2:D}", entryType, fsi.FullName, fsi.CreationTime);
}

注解

例如,对于文件 c:\NewFile.txt,此属性返回“c:\NewFile.txt”。

有关常见 I/O 任务的列表,请参阅 常见 I/O 任务

适用于

产品 版本
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

另请参阅