File.Rename
Description
- Renames a file or files, effectively moving it to the new path.
Syntax
- File.Rename(source, destination)
Parameters
- source
- (string) full path to the file/s to be renamed
- Use wildcards to rename groups of files.
- destination
- (string) path to the new file/s location
- If destination does not included a file name, the source file's name is used.
Examples
- File.Rename(?"c:\mypath\in.txt", ?"c:\output\out.txt")
- Renames "c:\mypath\in.txt" to "c:\output\out.txt".
- File.Rename(?"c:\docs\*.txt", ?"c:\backup\")
- Use the "*" wildcard to that specify all text files in "c:\docs" are to be renamed (i.e. moved) to folder "c:\backup".
- File.Rename(?"c:\mydocs\file?.txt", ?"c:\logs")
- Uses the "?" wildcard to specify that all text files with a file name "file" plus one character & the extension .txt, should be moved to folder "c:\logs".
Notes
- This function is the same as File.Move().