Lazarus

Free Pascal => Beginners => Topic started by: JLWest on January 23, 2021, 04:53:45 am

Title: (Solved)Rename Directory
Post by: JLWest on January 23, 2021, 04:53:45 am
Is there a function to rename a directory. I see nothing in fileutils or Lazfileutils.
Thanks
Title: Re: Rename Directory
Post by: lucamar on January 23, 2021, 05:54:29 am
A shot in the dark but, have you tried whether any of the RenameFile() or RenameFileUTF8() functions work if you pass them a directory name?
Title: Re: Rename Directory
Post by: trev on January 23, 2021, 07:28:21 am
This works for me in FreeBSD and macOS and Windows 10:

Code: Pascal  [Select][+][-]
  1. program renamedir;
  2.  
  3. uses
  4.   sysutils;
  5.  
  6. begin
  7. if (renamefile('testdir1','testdir2')) then
  8.   WriteLn('Rename succeeded!')
  9. else
  10.   WriteLn('Rename failed!');
  11. end.
Title: Re: Rename Directory
Post by: JLWest on January 23, 2021, 08:22:52 am
Thanks I'll try in the morning.
TinyPortal © 2005-2018