Deleting a file to recycle bin
-
How do I delete a file so that it goes to recycle bin, the following code doesnt seem to work?
static void delete_file() { SHFILEOPSTRUCT shf; int ret = 0; shf.wFunc = FO_DELETE; shf.pFrom = filename; shf.fFlags = FOF_ALLOWUNDO; if(0 != (ret = SHFileOperation(&shf)) { printf("could'nt delete \"%s\" to recycle bin (err=%d/%ld)\n", filename, ret, GetLastError()); } }
thanks! -
How do I delete a file so that it goes to recycle bin, the following code doesnt seem to work?
static void delete_file() { SHFILEOPSTRUCT shf; int ret = 0; shf.wFunc = FO_DELETE; shf.pFrom = filename; shf.fFlags = FOF_ALLOWUNDO; if(0 != (ret = SHFileOperation(&shf)) { printf("could'nt delete \"%s\" to recycle bin (err=%d/%ld)\n", filename, ret, GetLastError()); } }
thanks!pFrom must be double terminated. pTo must be set to NULL if not used. Paul DiLascia has a good article on using the Recycle Bin from MSDN April 2001. "My dog worries about the economy. Alpo is up to 99 cents a can. That's almost seven dollars in dog money" - Wacky humour found in a business magazine
-
How do I delete a file so that it goes to recycle bin, the following code doesnt seem to work?
static void delete_file() { SHFILEOPSTRUCT shf; int ret = 0; shf.wFunc = FO_DELETE; shf.pFrom = filename; shf.fFlags = FOF_ALLOWUNDO; if(0 != (ret = SHFileOperation(&shf)) { printf("could'nt delete \"%s\" to recycle bin (err=%d/%ld)\n", filename, ret, GetLastError()); } }
thanks!