[SOLVED] Delete file OK; delete dir access denied lazarus / 34-Windows ---------------------------------------------------------------------- lorenzo · 2021-10-01 16:25 There are over a hundred 'access is denied' threads and I'm sorry to add another. Weeding out old-ish backups, I wrote a simple prog to delete files from one drive when the same name/content was on a second drive.  DeleteFile( name ) worked just fine, and took a few thousand files off my USB memory stick. That left some empty directories, which I also wanted to delete.  Irritatingly the function RemoveDir( name ) returned false and did not carry out the removal.  I tried name with and without the final slash. RemoveDirUTF8 and DeleteDirectory didn't help.  Using     {$I-}     RmDir( name );     {$I+}     IOresult ... I turned up the error code 5, Access is Denied. I cannot see why I can delete files but not dirs on the same (USB) drive. Can anyone shine a light on this please? Windows 10, up to date.  Lazarus 2.0.12.  Unit is headed {$mode objfpc}{$H+}. ---------------------------------------------------------------------- loaded · 2021-10-01 16:51 In the directories; -Hidden Files -Are you sure there are no Hidden Operating System Files? For manual control ; Control Panel - File Explorer Options-View Title You can review the options below. ---------------------------------------------------------------------- lorenzo · 2021-10-02 03:19 That's it, loaded.  Thank you.  I feel stupid for not having thought of it before. In turns it raises the question why FindFirst etc failed to turn up the files.  I have found a useful thread https://forum.lazarus.freepascal.org/index.php?topic=26705.0 on that point so I have more work to do and more to learn.  Meanwhile I am marking this thread solved. Thanks again.