Public Properties and Methods of FileInfo Class
This section describes public properties and methods of the FileInfo class. Name, DirectoryName, Extension, CreationTime and Length are examples of FileInfo public properties.
System.IO.FileInfo class offers the following key public properties:
- Attributes - Gets or sets the attributes for the current file or directory.
- CreationTime - Gets or sets the creation time of the current file or directory.
- Directory - Gets an instance of the parent directory.
- DirectoryName - Gets a string representing the directory's full path.
- Exists - Gets a value indicating whether a file exists.
- Extension - Gets the string representing the extension part of the file.
- FullName - Gets the full path of the directory or file.
- IsReadOnly - Gets or sets a value that determines if the current file is read only.
- LastAccessTime - Gets or sets the time the current file or directory was last accessed.
- LastWriteTime - Gets or sets the time when the current file or directory was last written to.
- Length - Gets the size, in bytes, of the current file.
- Name - Gets the name of the file.
System.IO.FileInfo class offers the following key public methods:
- CopyTo(String) - Copies an existing file to a new file, disallowing the overwriting of an existing file.
- Create() - Creates a file.
- Delete() - Permanently deletes a file.
- GetType() - Gets the Type of the current instance.
- MoveTo() - Moves a specified file to a new location, providing the option to specify a new file name.
- Open(FileMode, FileAccess) - Opens a file in the specified mode with read, write, or read/write access.
- Replace(String, String) - Replaces the contents of a specified file with the file described by the current FileInfo object, deleting the original file, and creating a backup of the replaced file.
Last update: 2012.
Table of Contents
About This Book
Introduction of C# (C Sharp)
Data Type and Variables
Logical Expressions and Conditional Statements
Arrays and Loop Statements
Data Type Features
Floating-Point Data Types
Passing Parameters to Methods
Execution Environment Class
Visual C# 2010 Express Edition
C# Compiler and Intermediate Language
Compiling C# Source Code Files
MSBuild - Microsoft Build Engine
Memory Usages of Processes
Multithreading in C#
Async Feature from C# 5
What Is FileInfo?
►Public Properties and Methods of FileInfo Class
Creating FileInfo Objects
FileVersionCopyFile.cs - Testing CopyTo() Method
WPF - Windows Presentation Foundation
Partial Classes and Partial Methods
PDF Printing Version