Delphi: Rename Folder
Tutorial by Delphian | Last update on 2021-05-12 | Created on 2012-08-09
In this tutorial I would like to show you, how you can rename a directory with Delphi.
We are using the ShellApi from Windows for this, so we have to write the unit ShellApi to our uses-clause:
uses ShellApi;
After that, we define a procedure called RenameFolder, with which we are able to rename the folder "FolderOld" to "FolderNew":
procedure RenameFolder(FolderOld, FolderNew: string); var ShellInfo: TSHFileOpStruct; begin ShellInfo.Wnd := 0; ShellInfo.wFunc := FO_RENAME; ShellInfo.pFrom := PChar(FolderOld); ShellInfo.pTo := PChar(FolderNew); SHFileOperation(ShellInfo); end;
Finally, here is a possible call of our procedure. Here we are renaming the folder "Folder" to "NewName":
procedure TForm1.Button1Click(Sender: TObject); begin RenameFolder('C:\Folder', 'C:\NewName'); end;
Have fun with renaming!
About the Author
The author has not added a profile short description yet.
Show Profile
Related Topics
Rename File to its Folder Name
Tutorial | 0 Comments
Windows Batch Script: Computer Shutdown
Tutorial | 2 Comments
Lazarus: Detect Operating System (Compiler Switch)
Tutorial | 0 Comments
Put Windows via Script into Hibernation or Sleep Mode
Tutorial | 0 Comments
Delphi/Lazarus: How to set up a Link to a Website in an Application
Tutorial | 0 Comments
Delphi: System-Wide HotKey
Tutorial | 1 Comment
XAMPP: How to set up SSL/HTTPS for local Projects
Tutorial | 4 Comments
Important Note
Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.
Participate
Ask your own question or write your own article on askingbox.com. That’s how it’s done.