C# - DirectoryInfo.FullName Property with Example

Learn, how to get complete path using FullName property? Here we will use class DirectoryInfo?
Submitted by IncludeHelp, on November 16, 2017 [Last updated : March 27, 2023]

DirectoryInfo.FullName

The FullName is a property of DirectoryInfo class, it returns the full (complete) path of given directory.

Syntax

string DirectoryInfo.FullName

Parameter(s)

  1. None

Return Value

Returns the complete path of given directory.

Example: C# program to get the full path of the given directory

using System;
using System.IO;

namespace ConsoleApplication1 {
  class Program {
    static void Main() {
      DirectoryInfo d = new DirectoryInfo("mydir");

      Console.WriteLine("FullName of directory:");
      Console.WriteLine(d.FullName);

    }
  }
}

Output

FullName of directory:
C:\Users\Arvind\Documents\Visual Studio 2010\Projects\ihelp\ConsoleApplication1\
ConsoleApplication1\bin\Debug\mydir

Explanation

In this program, we create an object of DirectoryInfo class and initialize with a "directory-name", then get complete path of given directory using FullName property of DirectoryInfo class.

Note: In above program, we need to remember, when we use "DirectoryInfo" class, System.IO namespace must be included in the program.

C#.Net DirectoryInfo Class Programs »

Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.