Move Method

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Moves a specified file to a new location, providing the option to specify a new file name.

Namespace:  System.IO
Assembly:  System.IO (in System.IO.dll)

public static void Move(
	string sourceFileName,
	string destFileName
)

Parameters

sourceFileName
Type: System..::..String
The name of the file to move.
destFileName
Type: System..::..String
The new path for the file.

This method works across disk volumes, and it does not throw an exception if the source and destination are the same. Note that if you attempt to replace a file by moving a file of the same name into that directory, you get an IOException. You cannot use the Move method to overwrite an existing file.

The sourceFileName and destFileName arguments are permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. To obtain the current working directory, see GetCurrentDirectory.

If you try to move a file across disk volumes and that file is in use, the file is copied to the destination, but it is not deleted from the source.

Show: