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
| AppendText | Opens the text file in append mode and returns a StreamWriter object |
| CopyTo | Copies the file to another path |
| Create | Creates the file |
| CreateText | Creates a text file and returns a StreamWriter object |
| Decrypt | |
| Delete | Deletes the file |
| Encypt | |
| MoveTo | Moves the file to another path |
| Open | Opens the current file with specified mode, access and share, returns a FileStream object |
| OpenRead | Opens the file in read mode and returns FileStream object |
| OpenText | Opens the current file in read mode and returns a StreamReader object |
| OpenWrite | Opens the file in write mode and returns FileStream object |
| Replace |
Properties
| Directory | Returns the DirectoryInfo object for the parent directory |
| DirectoryName | Returns the name of the parent directory |
| Exists | Returns true if the file exists |
| IsReadOnly | |
| Length | Returns the length of the file |
| Name | Returns 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
FileAttribute Values
IO.FileAttributes.Archive - 32
IO.FileAttributes.Compressed - 2048
IO.FileAttributes.Device - 64
IO.FileAttributes.Directory = 16
IO.FileAttributes.Encypted - 16384
IO.FileAttributes.Hidden - 2
IO.FileAttributes.Normal - 128
IO.FileAttributes.NotContentIndexed - 8192
IO.FileAttributes.Offline - 4096
IO.FileAttributes.ReadOnly - 1
IO.FileAttributes.ReparsePoint - 1024
IO.FileAttributes.SparseFile - 512
IO.FileAttributes.System - 4
IO.FileAttributes.Temporary - 256
© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrevNext