Delete to recycle bin with long filenames - How do you do it

Discuss development issues and submit patches here
Post Reply
tom82
Posts: 2
Joined: Wed May 30, 2012 7:59 pm

Delete to recycle bin with long filenames - How do you do it

Post by tom82 »

I'm quite amazed by Explorer++.

My own sw can delete files to the recycle bin. But it fails if path+name are longer than 256 chars. Error code 0x7c (DE_INVALIDFILES). I checked your source code, but didn't find anything special. You're using SHFileOperation, just like I do.

Why does it work in Explorer++? What magic did you use?

Please help me!

Tom
David Erceg
Site Admin
Posts: 933
Joined: Sat Apr 18, 2009 1:46 am

Re: Delete to recycle bin with long filenames - How do you d

Post by David Erceg »

Hi Tom,

I can't say that it's doing anything special! Are you sure your filename list is double-null terminated?
tom82
Posts: 2
Joined: Wed May 30, 2012 7:59 pm

Re: Delete to recycle bin with long filenames - How do you d

Post by tom82 »

Hi David,

thanks for your reply. Yes, I'm quite sure. And for "normal" filenames my code works nicely.

Here it is:

Code: Select all

      char Buffer[2048+4];

      strncpy_s (Buffer, 2048+4, filename, 2048);
      Buffer[strlen(Buffer)+1]=0;

      SHFILEOPSTRUCT s;
      s.hwnd                  = NULL;
      s.wFunc                 = FO_DELETE;
      s.pFrom                 = Buffer;
      s.pTo                   = NULL;
      s.fFlags                = FOF_ALLOWUNDO | (bConfirm?0:FOF_NOCONFIRMATION) | FOF_SILENT|FOF_NOERRORUI;
      s.fAnyOperationsAborted = false;
      s.hNameMappings         = NULL;
      s.lpszProgressTitle     = NULL;

      int rc = SHFileOperation(&s);

      return (rc==0);
(I know, hard-coding the buffer isn't perfect. But it's not the problem here...;-)

Any ideas?

Is there anything that can be enabled in the manifest file or a Windows API function to tell Window that this program can handle long filenames?
Post Reply