Get root root information in CSharp

Description

The following code shows how to get root root information.

Example


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


public class DirectoryRoot
{
    public static void Main()
    {
        string dir = @"C:\test";
        try
        {
            //Set the current directory.
            Directory.SetCurrentDirectory(dir);
        }
        catch (DirectoryNotFoundException e)
        {
            Console.WriteLine("The specified directory does not exist. {0}", e);
        }
        Console.WriteLine("Root directory: {0}", Directory.GetDirectoryRoot(dir));
        Console.WriteLine("Current directory: {0}", Directory.GetCurrentDirectory());
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    IO »




File Attribute
File Security
Directory Attribute
Directory Recursive
Binary File
Text Field
Buffered IO
Create Copy Delete Move
CSV
Drive
File System Watcher
Isolated Storage
MemoryStream
Serialize
Zip