FileInfo

The FileInfo class represents a single file
This class inherits from the FileSystemInfo virtual class
You can create a reference to a FileInfo object by using its constructor method


System.IO.FileInfo oFileInfo; 
oFileInfo = new System.IO.FileInfo("C:\Temp\textfile.txt")

This class provides instance methods for manipulating files.


System.IO.FileInfo oFileInfo; 
oFileInfo = oDirectoryInfo.GetFiles;

Doesn't accept URI notation


Properties and Methods

NameReturns the name of the file
FullName Returns the full name including its full path
ExtensionReturns the extension of the file
ExistsReturns true if the file exists
AttributesSets or returns the attributes of the file as a bit-coded FileAttrbutes value ?
CreationTimeSets or returns the creation time of the file (Date value)
LastWriteTimeSets or returns the last write time for the file (Date value)
LastAccessTimeSets or returns the last access time for the file (Date value)
RefreshRefreshes the properties of this object
AppendTextOpens the text file in append mode and returns a StreamWriter object
CopyToCopies the file to another path
CreateCreates the file
CreateTextCreates a text file and returns a StreamWriter object
DeleteDeletes the file
DirectoryReturns the DirectoryInfo object for the parent directory
DirectoryNameReturns the name of the parent directory
LengthReturns the length of the file
MoveTo(destpath)Moves the file to another path
OpenOpens the current file with specified mode, access and share, returns a FileStream object
OpenReadOpens the file in read mode and returns FileStream object
OpenTextOpens the current file in read mode and returns a StreamReader object
OpenWriteOpens the file in write mode and returns FileStream object



Name

Returns the name of the file



FullName

Returns the full name including its full path



Extension

Returns the extension of the file



Exists

Returns true if the file exists



Attributes

Sets or returns the attributes of the file as a bit-coded FileAttrbutes value ?



CreationTime

Sets or returns the creation time of the file (Date value)


LastWriteTime

Sets or returns the last write time for the file (Date value)


LastAccessTime

Sets or returns the last access time for the file (Date value)



Refresh

Refreshes the properties of this object



Delete

Deletes the file



Length

Returns the length of the file



Directory

Returns the DirectoryInfo object for the parent directory



DirectoryName

Returns the name of the parent directory



Create

Creates the file



MoveTo(destpath)

Moves the file to another path

MoveTo(destpath) 

CopyTo

Copies the file to another path

CopyTo(destfile [,overwrite]) 

Open

Opens the current file with specified mode, access and share, returns a FileStream object

Open(mode [,access [,share]]]) 

OpenRead

Opens the file in read mode and returns FileStream object



OpenWrite

Opens the file in write mode and returns FileStream object



OpenText

Opens the current file in read mode and returns a StreamReader object



CreateText

Creates a text file and returns a StreamWriter object



AppendText

Opens the text file in append mode and returns a StreamWriter object




© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext