C# FileInfo Exists

Description

FileInfo Exists Gets a value indicating whether a file exists.

Syntax

FileInfo.Exists has the following syntax.


public override bool Exists { get; }

Example

Gets a value indicating whether a file exists.


using System;//from  ww  w.j  av  a  2  s.  c o m
using System.IO;
using System.Security.AccessControl;

class FileExample
{
    public static void Main()
    {
        string FileName = @"c:\MyTest.txt";
        FileInfo fInfo = new FileInfo(FileName);
        Console.WriteLine(fInfo.Exists);
                
    }
}

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