C# DirectoryInfo Parent

Description

DirectoryInfo Parent Gets the parent directory of a specified subdirectory.

Syntax

DirectoryInfo.Parent has the following syntax.


public DirectoryInfo Parent { get; }

Example

Gets the parent directory of a specified subdirectory.


using System;//  ww w  .  j  a  v a 2s .c o  m
using System.IO;

class GetAName
{
    public static void Main(string[] args)
    {
        DirectoryInfo dir = new DirectoryInfo(".");
        DirectoryInfo dirName = dir.Parent;
        Console.WriteLine(dirName);
    }
}




















Home »
  C# Tutorial »
    System.IO »




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