Table of Contents

Class FileInfo

Namespace
System.IO
Assembly
System.IO.FileSystem.dll

Provides properties and instance methods for the creation, copying, deletion, moving, and opening of files, and aids in the creation of FileStream objects. This class cannot be inherited.

public sealed class FileInfo : FileSystemInfo
Inheritance
FileInfo
Inherited Members
Extension Methods

Constructors

FileInfo(string)

Initializes a new instance of the FileInfo class, which acts as a wrapper for a file path.

public FileInfo(string fileName)

Parameters

fileName string

Properties

Directory

Gets an instance of the parent directory.

public DirectoryInfo Directory { get; }

Property Value

DirectoryInfo

DirectoryName

Gets a string representing the directory's full path.

public string DirectoryName { get; }

Property Value

string

Exists

Gets a value indicating whether the file or directory exists.

public override bool Exists { get; }

Property Value

bool

Length

Gets the size, in bytes, of the current file.

public long Length { get; }

Property Value

long

Name

Gets the name of the file.

public override string Name { get; }

Property Value

string

Methods

Create()

Creates a file.

public FileStream Create()

Returns

FileStream

A new file.

Delete()

Deletes a file or directory.

public override void Delete()

HandleRefreshError()

Handler for the case when the file or directory does not exist.

protected override void HandleRefreshError()

ToString()

Returns the original path that was passed to the FileInfo constructor. Use the FullName or Name property for the full path or file name.

public override string ToString()

Returns

string

A string representing the path.