Question about deleting files and the trash
Question about deleting files and the trash
Hello,
If I delete a file in my application, of course, the file is gone.
But is there a possibility to delete file in a way that the deleted files can be restored from the trash?
Moving to $Recycle.Bin doesn't seem to be enough.
Thank you.
If I delete a file in my application, of course, the file is gone.
But is there a possibility to delete file in a way that the deleted files can be restored from the trash?
Moving to $Recycle.Bin doesn't seem to be enough.
Thank you.
Regards,
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
- Antonio Linares
- Site Admin
- Posts: 42259
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Question about deleting files and the trash
Dear Michel,
It seems as this code has to be used:
So basically we have to use SHFileOperation() from FWH. We are going to build an example.
It seems as this code has to be used:
Code: Select all | Expand
#include <stdio.h>
#include <windows.h>
#include <shellapi.h>
#define FO_DELETE 3 //Delete the files specified in pFrom.
#define FOF_ALLOWUNDO 0x40 //Preserve undo information, if possible.
#define FOF_NOCONFIRMATION 0x0010 //Do not ask the user to confirm selection.
typedef struct _SHFILEOPSTRUCT {
HWND hwnd;
UINT wFunc;
LPCSTR pFrom;
LPCSTR pTo;
FILEOP_FLAGS fFlags;
BOOL fAnyOperationsAborted;
LPVOID hNameMappings;
LPCSTR lpszProgressTitle;
} SHFILEOPSTRUCT, *LPSHFILEOPSTRUCT;
int main()
{
SHFILEOPSTRUCT shf;
shf.wFunc = FO_DELETE;
shf.pFrom = "C:\\myfile.txt\0\0"; //File to delete
shf.fFlags = FOF_ALLOWUNDO | FOF_NOCONFIRMATION;
int result = SHFileOperation(&shf);
if (result == 0)
{
printf("File deleted successfully.\n");
}
else
{
printf("Error: %d\n", result);
}
return 0;
}
Re: Question about deleting files and the trash
hi,
i´m not sure if there is a simple API Call. i use SHFile() Operation like Explorer
when set Flag FOF_ALLOWUNDO it will move deleted Files into Recycle-bin
have a look at https://forums.fivetechsupport.com/view ... hp?t=42417
i´m not sure if there is a simple API Call. i use SHFile() Operation like Explorer
when set Flag FOF_ALLOWUNDO it will move deleted Files into Recycle-bin
have a look at https://forums.fivetechsupport.com/view ... hp?t=42417
greeting,
Jimmy
Jimmy
Re: Question about deleting files and the trash
Hello Jimmy,
Deleting files by using ShFileOperation() works fine.
But the deleted files are not moved to the recycle bin yet.
So I need to set the flag FOF_ALLOWUNDO.
But how do I do that?
Thanks.
Deleting files by using ShFileOperation() works fine.
But the deleted files are not moved to the recycle bin yet.
So I need to set the flag FOF_ALLOWUNDO.
But how do I do that?
Thanks.
Regards,
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
- Antonio Linares
- Site Admin
- Posts: 42259
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Question about deleting files and the trash
Dear Michel,
It is the fifth parameter when you call SHFILEOPERATION()
It is the fifth parameter when you call SHFILEOPERATION()
Re: Question about deleting files and the trash
Antonio,
I tried that, but there is no chance. No file in the recyle bin.
This is the code I use:Thanks a lot.
I tried that, but there is no chance. No file in the recyle bin.
This is the code I use:
Code: Select all | Expand
#define FO_DELETE 0x0003
#define FOF_ALLOWUNDO 0x0040
******************************************************************************
DeleteFile( DOCDOEL, ArcLst ) // DOCDOEL = file that has to be deleted
// ArcLst = Dialog Box
******************************************************************************
static function DeleteFile( cFileName , oDlg )
return SHFileOperation( oDlg:hWnd, FO_DELETE , cFileName + Chr( 0 ) ,, FOF_ALLOWUNDO )
Regards,
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
- Antonio Linares
- Site Admin
- Posts: 42259
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Question about deleting files and the trash
Please do:
MsgInfo( DeleteFile( DOCDOEL, ArcLst ) )
and let us know what you get
MsgInfo( DeleteFile( DOCDOEL, ArcLst ) )
and let us know what you get
Re: Question about deleting files and the trash
Antonio,
The answer I get is : 0,00
The answer I get is : 0,00
Regards,
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
- Antonio Linares
- Site Admin
- Posts: 42259
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Question about deleting files and the trash
https://learn.microsoft.com/en-us/windo ... operationa
I can't understand why they don't appear at the recycle bin
so it seems as it is properly doing it...Returns zero if successful; otherwise nonzero
I can't understand why they don't appear at the recycle bin
Re: Question about deleting files and the trash
Hello Secarse:
Have you tried moving it to the trash without deleting it? It disappears from the source folder and goes to the trash can.
greeting
Javier Lloris
javierllorisprogramador@gmail.com
Blogs personales:
Programación: https://javierlloris.blogspot.com/
Japonés: https://bitacorajaponesa.blogspot.com/
Cubos de Rubik: https://www.instagram.com/jllorisperson ... 2ybz0gmvul
Tengo una colección de unos 100 cubos de todo tipo de formas geométricas, todos resueltos, en instagram solo hay unos cuentos cubos.
Have you tried moving it to the trash without deleting it? It disappears from the source folder and goes to the trash can.
greeting
Javier Lloris
javierllorisprogramador@gmail.com
Blogs personales:
Programación: https://javierlloris.blogspot.com/
Japonés: https://bitacorajaponesa.blogspot.com/
Cubos de Rubik: https://www.instagram.com/jllorisperson ... 2ybz0gmvul
Tengo una colección de unos 100 cubos de todo tipo de formas geométricas, todos resueltos, en instagram solo hay unos cuentos cubos.
Libreria: FWH/FWH1109 + Harbour 5.8.2 + Borland C++ 5.8.2
Editor de Recursos: PellecC
ADA, OURXDBU
S.O: XP / Win 7 /Win10
Blog: http://javierlloris.blogspot.com.es/
e-mail: javierllorisprogramador@gmail.com
Editor de Recursos: PellecC
ADA, OURXDBU
S.O: XP / Win 7 /Win10
Blog: http://javierlloris.blogspot.com.es/
e-mail: javierllorisprogramador@gmail.com
Re: Question about deleting files and the trash
Javier,
Just moving to the trash, how do I do that?
To everyone, any idea what is going wrong?
Thanks.
Just moving to the trash, how do I do that?
To everyone, any idea what is going wrong?
Thanks.
Regards,
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
Re: Question about deleting files and the trash
hi,
have you try my CODE Sample https://forums.fivetechsupport.com/view ... hp?t=42417
it work with Recylebin
Note : you must use "full-Path"
have you try my CODE Sample https://forums.fivetechsupport.com/view ... hp?t=42417
it work with Recylebin
Note : you must use "full-Path"
https://learn.microsoft.com/en-us/windo ... eopstructaIf pFrom is set to a file name without a full path, deleting the file with FO_DELETE does not move it to the Recycle Bin, even if the FOF_ALLOWUNDO flag is set. You must provide a full path to delete the file to the Recycle Bin.
greeting,
Jimmy
Jimmy