System.IO.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


Methods

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
Decrypt 
DeleteDeletes the file
Encypt 
MoveToMoves 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
Replace 

Properties

DirectoryReturns the DirectoryInfo object for the parent directory
DirectoryNameReturns the name of the parent directory
ExistsReturns true if the file exists
IsReadOnly 
LengthReturns the length of the file
NameReturns the name of the file

MoveTo

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



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