You are on page 1of 8

File System in C#

File System
Object Model

BinaryReader

System. Object

BinaryWriter

Dir

FileSystemInfo

DirectoryInfo
TextWriter

StringWriter

FileInfo

TextReader

StreamWriter

StreamReader

StringReader

Class

Purpose

BinaryReader and BinaryWriter

Read and Write the primitive data


types

DirectoryInfo and FileInfo

Create, delete and move the files


and directories. Get the specific
information about the files by
making use of properties defined in
these classes

FileStream

Access the files in a random fashion

MemoryStream

Access the data stored in memory

StreamWriter and
StreamReader

Read and write the textual


information

StringReader and StringWriter

Read and write the textual


information from a string buffer

DirectoryInfo Class
Method

Description

Create

Creates a directory

Createsubdirectory

Creates a subdirectory or subdirectories on the


specified path

Delete

Deletes a directory and its content

GetDirectories

Returns the subdirectories of current directory

GetFiles

Returns the file list from current directory

GetFileSystemInfos Retrieves an array FileSystemInfo objects


representing files and subdirectories of current
directory
MoveTo

Moves a DirectoryInfo instance and its contents


to a new path

DirectoryInfo Class
Property

Description

Attributes

Get or Sets the attributes of current


FileSystemInfo

CreationTime

Get or Sets the creation time of current


FileSystemInfo objects

Exists

Get a value indicating whether directory exists

FullName

Gets the full path of the directory or file

LastAccessTime

Gets or Sets the time the current file or directory


was last accessed

LastWriteTime

Gets or Sets the time the current file or directory


was last written to

Name

Gets the name of current DirectoryInfo instance

Parent

Gets the parent directory of specified subdirectory

FileInfo Class
Method

Description

Append

Opens the file and adds the data

AppenText

Creates the StreamWriter that appends the text to the file

CopyTo

Copies an existing file to new file

Create

Creates a file

CreateText

Creates a StreamWriter that writes a new text file

Delete

Permanently deletes a file

MoveTo

Moves the specified file to new location

Open

Opens the file with various read/write and sharing


privileges

OpenRead

Creates a read only file stream

OpenText

Creates a StreamReader that reads from an existing text


file

OpenWrite

Creates a write-only filestream

Property

Description

Attributes

Get or Sets the attributes of current FileSystemInfo

CreationTime

Get or Sets the creation time of current FileSystemInfo


objects

Exists

Get a value indicating whether file exists

FullName

Gets the full path of the directory or file

LastAccessTime

Gets or Sets the time the current file or directory was last
accessed

LastWriteTime

Gets or Sets the time the current file or directory was last
written to

Name

Gets the name of the file

Length

Gets the size, in bytes, of the current file

Directory

Gets the instance of a parent directory

DirectoryName

Gets a string representing the directorys full path

IsReadOnly

Gets or Sets a value that determines the current file is


read only

THANK YOU

You might also like