Open In App

C# Program to Demonstrate the Use of FullName Property

Improve
Improve
Like Article
Like
Save
Share
Report

DirectoryInfo class provides different types of methods and properties that are used to perform operations on directories and sub-directories like creating, moving, etc and FullName property is one of them. This property is used to find the full path of the directory or the specified file.

Syntax:

public virtual string FullName { get; }

Return: It will return a string that contains the full path of the current directory or file.

Exception: This property will throw the following exceptions:

  • PathTooLongException: This exception will occur when the path and the file name exceed the system-defined maximum length.
  • SecurityException: This exception will occur when the caller doesn’t have enough permissions.

Example:

C#




// C# program to demonstrate the use of 
// FullName property
using System;
using System.IO;
  
class GFG{
  
static void Main()
{
      
    // Creating a object which contain the 
    // name of the directory 
    DirectoryInfo full_name = new DirectoryInfo("vignan");
  
    Console.WriteLine("FullName");
      
    // Finding the full path of the directory 
    // Using FullName property
    Console.WriteLine(full_name.FullName);
}
}


Output:

FullName
/home/cg/root/8057718/vignan

Last Updated : 01 Feb, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads