C# FileInfo Directory

Description

FileInfo Directory Gets an instance of the parent directory.

Syntax

FileInfo.Directory has the following syntax.


public DirectoryInfo Directory { get; }

Example

Gets an instance of the parent directory.


using System;/*from   www.  jav a  2s  . c o m*/
using System.IO;

public class DirectoryTest 
{
    public static void Main() 
    {
        FileInfo fi = new FileInfo("temp.txt");
        DirectoryInfo di = fi.Directory;

        Console.WriteLine(di.FullName);


    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.IO »




BinaryReader
BinaryWriter
Directory
DirectoryInfo
DriveInfo
File
FileInfo
FileStream
MemoryStream
Path
StreamReader
StreamWriter
StringReader
StringWriter