C# FileInfo Name

Description

FileInfo Name Gets the name of the file.

Syntax

FileInfo.Name has the following syntax.


public override string Name { get; }

Example

Gets the name of the file.


using System;/*from w  w w. ja va 2 s .  c  o  m*/
using System.IO;

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

        Console.WriteLine(fi.Name);
    }
}

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