Delete a file to the recycle bin from C++
Today, I was looking for a way to delete a file to the recycle bin using C++, but couldn’t find any simple example, so here it is:
SHFILEOPSTRUCT operation; operation.wFunc = FO_DELETE; operation.pFrom = "c:\\file\to\delete.txt"; operation.fFlags = FOF_ALLOWUNDO; SHFileOperation(&operation);
Tags: SHFileOperation, simple example, Win32
November 25th, 2009 at 15:26
1) operation.pFrom must be end with double zero
2) operation.fFlags = FOF_ALLOWUNDO|FOF_NO_UI|FOF_NORECURSION;