Description |
Moves the SourcePath file or folder to the TargetPath file or folder.
For a folder move, the TargetPath folder must not yet exist - the target is the name of the new folder, not its location.
|
| Notes | Static methods are not methods of an object - they are simply class functions or procedures available at any time.
|
|
Microsoft MSDN Links |
System.IO
System.IO.Directory
|
|
|
A simple example |
program Project1;
{$APPTYPE CONSOLE}
uses
System.IO;
var
BasePath : String;
Folders : Array of String;
i : Integer;
begin
// Create a base folder
BasePath := 'C:\Base';
System.IO.Directory.CreateDirectory(BasePath);
// And a sub-folder
System.IO.Directory.CreateDirectory(BasePath+'\SubFolder');
// List the folders under C:\Base
Folders := System.IO.Directory.GetDirectories(BasePath);
for i := 0 to Length(Folders)-1 do
Console.WriteLine(Folders[i]);
// Now move the sub folder to a new name
System.IO.Directory.Move(BasePath+'\SubFolder', BasePath+'\NewFolder');
// List the folders under C:\Base
Folders := System.IO.Directory.GetDirectories(BasePath);
for i := 0 to Length(Folders)-1 do
Console.WriteLine(Folders[i]);
// Now delete this nest of folders
System.IO.Directory.Delete(BasePath, true);
Console.Readline;
end.
| Show full unit code | C:\Base\SubFolder
C:\Base\NewFolder
|
|
|
|