What is the procedure for renaming a folder (directory) using Delphi code? Do I have to create a new folder, move the files and then delete the old folder? Or can I simply rename a folder?
I have been looking through the help files but I am not having any luck.
Use the MoveFile API if it's on the same disk, otherwise you WILL likely have to Create the Filestructure on the other disk for yourself...
Something like this:
While Not ALL_DONE Do Begin
MkDir(DestinationFolders);
CopyFile(SourceFile, TargetFile);
If CopyOk Then
DeleteFile(SourceFile);
End;
this works for all local disks (maybe network)
uses shellapi;
procedure TForm1.Button1Click(Sender
var sh: SHFILEOPSTRUCT;
begin
FillChar(sh, SizeOf(sh), 0);
sh.wFunc:=FO_MOVE;
sh.pFrom:=PChar(edit1.Text
sh.pTo:=PChar(edit2.Text);
SHFileOperation(sh);
end;