Link to home
Start Free TrialLog in
Avatar of bjames
bjames

asked on

Renaming a Folder

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.

Thanks
Avatar of raidos
raidos

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;

Regards
//raidos
huh ?
simply use RenameFile(OldDirName, NewDirName);
works :)
ASKER CERTIFIED SOLUTION
Avatar of Lee_Nover
Lee_Nover

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bjames

ASKER

Perfect! Exactly what I needed.

Thanks