Jump to content
Tuts 4 You

Do you know any simple file restore tools or alternative function for DeleteFile?


LCF-AT

Recommended Posts

Posted

Hi guys,

another question today. So I did delete few files accidentally by using the Window function DeleteFIle in my app (just some text files to delete) and if that happens the files are gone and not find in trashcan etc. So my question is how to get them back (so simple as possible)? I tried using Recuva app I found quickly on internet what was showing some files I could not find in trashcan but not all I did delete.

Is there any other function instead of using DeleteFile what does delete the files I want BUT just moving them into trashcan only like Windows itself does?

greetz

Teddy Rogers
Posted

You will need to use Shell API operations to make use of the trashcan/ recycle bin. Refer to SHFileOperationW and read through the remarks section...

Quote

When used to delete a file, SHFileOperation permanently deletes the file unless you set the FOF_ALLOWUNDO flag in the fFlags member of the SHFILEOPSTRUCT structure pointed to by lpFileOp. Setting that flag sends the file to the Recycle Bin. If you want to simply delete a file and guarantee that it is not placed in the Recycle Bin, use DeleteFile.

...or, preferably, if being used on operating systems Vista and above use IFileOperation and refer to IFileOperation::SetOperationFlags...

Quote

Note  If this method is not called, the default value used by the operation is FOF_ALLOWUNDO | FOF_NOCONFIRMMKDIR.

...also take note of FOFX_RECYCLEONDELETE flag...

Quote

Introduced in Windows 8. When a file is deleted, send it to the Recycle Bin rather than permanently deleting it.

Ted.

  • Like 2
Posted

Hi again,

thanks for the info Ted. Also found a MASM example proc using that function like this...

.data
fname1 db "c:\_recyclefiletest.000",0

invoke RecycleFile,ADDR fname1


RecycleFile proc pszFullPath:DWORD
LOCAL fo:SHFILEOPSTRUCT

mov fo.hwnd, NULL
mov fo.wFunc, FO_DELETE
m2m fo.pFrom, pszFullPath
mov fo.pTo, NULL
mov fo.fFlags,FOF_ALLOWUNDO
invoke SHFileOperation,ADDR fo

ret
RecycleFile endp

...so I did not test it yet but I would like to know whether I can also use same path names as I did with DeleteFile function too? Just asking because there is anything telling me using just full paths only when using this SH function. So in my case when using DeleteFile I'm using paths like this...

invoke wsprintf,addr CLIPBOARDBUFFER,chr$(".\App_Files\%s.txt"),addr Buffer
invoke DeleteFile,addr CLIPBOARDBUFFER

....which starting with .\ because I just want to delete files in specific app folder where the executable is stored. So can I keep those paths like above when using the SH function instead DeleteFile or have I to change that too?

greetz

  • Like 1
Teddy Rogers
Posted

If you mean using periods to represent current and parent directories, you need to use a full path to make use of the Recycle Bin. Without a full path it will act similar to DeleteFile, you will not be able to restore from the Recycle Bin...

Ted.

  • Like 2
Posted

@LCF-AT  if you wanna just to recover accidentally deleted file I"d recommendUFS Explorer Professional Recovery  SW

 

 

  • Like 2
Posted

Hi guys,

hhmmm, sounds bad Ted. Then I need to rewrite the code again just because of using full path string.

@jackyjask

Thanks for the info but I was more looking for a more simple app what can do that just in case I did delete some files like I did using DeleteFile or manually etc. Also some free one if possible. I do remember long time ago I was using R-Studio app but can't find it anymore on my system so I think the old version had any other name (not R-studio) but I don't remember the app name to find it.

greetz

  • Like 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...