Click or drag to resize

ExtensionsFileInfoRename Method

Renames a file.

Namespace:  Cauldron
Assembly:  Cauldron (in Cauldron.dll) Version: 3.2.0.2
Syntax
public static FileInfo Rename(
	this FileInfo fileInfo,
	string newName
)

Parameters

fileInfo
Type: System.IOFileInfo
The file to rename.
newName
Type: SystemString
The new name of the file.

Return Value

Type: FileInfo
A new instance of FileInfo representing the renamed file.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type FileInfo. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Exceptions
ExceptionCondition
FileNotFoundExceptionfileInfo does not exist.
ArgumentNullExceptionnewName is null.
ArgumentExceptionnewName is empty, contains only white spaces, or contains invalid characters.
IOExceptionAn I/O error occurs, such as the destination file already exists or the destination device is not ready.
SecurityExceptionThe caller does not have the required permission.
UnauthorizedAccessExceptionnewName is read-only or is a directory.
DirectoryNotFoundExceptionThe specified path is invalid, such as being on an unmapped drive.
NotSupportedExceptionnewName contains a colon (:) in the middle of the string.
PathTooLongException The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
See Also