System. Rename File(String, String) Method
Renames a file.
public: static void RenameFile(System::String ^ file, System::String ^ newName);
public static void RenameFile (string file, string newName);
static member RenameFile : string * string -> unit
Public Shared Sub RenameFile (file As String, newName As String)
File to be renamed.
New name of file.
newName contains path information or ends with a backslash (\).
Nothing or an empty string.
The directory does not exist.
There is an existing file or directory with the name specified in
The path exceeds the system-defined maximum length.
A file or directory name in the path contains a colon (:) or is in an invalid format.
The user lacks necessary permissions to view the path.
The user does not have required permission.
This example renames the file
C:\Test.txt" to the path and file name of the file that you want to rename.
This method cannot be used to move a file; use the MoveFile method to move and rename the file.
The following table lists an example of a task involving the
|Rename a file||How to: Rename a File in Visual Basic|