When debugging plugins that create temporary files for interim data storage that are subsequently deleted, it would be useful to be able to "undo" the deletion.
I know that os.remove(...) does not use the Recycle Bin, as that is difficult to implement with a cross-platform library. However, fhFileUtils also seems to do an immediate permanent deletion. As this is a Windows-only library, would it be possible to send the file or folder being deleted to the Recycle Bin instead of immediately deleting it? That would bring plugins in line with the core FH application.
* fhFileUtils not using Recycle Bin
- Mark1834
- Megastar
- Posts: 2147
- Joined: 27 Oct 2017 19:33
- Family Historian: V7
- Location: South Cheshire, UK
fhFileUtils not using Recycle Bin
Mark Draper
- tatewise
- Megastar
- Posts: 27087
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Re: fhFileUtils not using Recycle Bin
You say: "That would bring plugins in line with the core FH application."
However, in FH, 'Delete' typically does NOT send files to the Recycle Bin.
In Tools > Plugins if you Delete any Plugin it is gone forever.
In Query > All Custom Queries if you Delete any Query it is gone forever.
I think the deletion of any other custom files is similarly permanent.
I guess you are talking about the fhFileUtils deleteFile() function that uses FSO:DeleteFile().
There are no FSO functions that involve the Recycle Bin.
I tried using moveFile(sPath,sDest) with sDest set to such as "C:\\$Recycle.Bin\\Recycle Bin" without success.
The only method I could find that worked with a script is:
BUT the "delete" always involves a user confirmation dialogue and a Google search offers no solution.
An alternative would be to use moveFile(sPath,sDest) with sDest set to the Temporary folder.
However, in FH, 'Delete' typically does NOT send files to the Recycle Bin.
In Tools > Plugins if you Delete any Plugin it is gone forever.
In Query > All Custom Queries if you Delete any Query it is gone forever.
I think the deletion of any other custom files is similarly permanent.
I guess you are talking about the fhFileUtils deleteFile() function that uses FSO:DeleteFile().
There are no FSO functions that involve the Recycle Bin.
I tried using moveFile(sPath,sDest) with sDest set to such as "C:\\$Recycle.Bin\\Recycle Bin" without success.
The only method I could find that worked with a script is:
Code: Select all
require("luacom")
local shell = luacom.CreateObject("Shell.Application")
local path = shell:NameSpace(sPath) -- sPath is the parent folder
local file = path:ParseName(sFile) -- sFile is the filename to delete
file:InvokeVerb("delete")
An alternative would be to use moveFile(sPath,sDest) with sDest set to the Temporary folder.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
- Mark1834
- Megastar
- Posts: 2147
- Joined: 27 Oct 2017 19:33
- Family Historian: V7
- Location: South Cheshire, UK
Re: fhFileUtils not using Recycle Bin
Fair enough - it looks more complicated than I thought. Even using 'del' from a command prompt doesn't have an option to use the Recycle Bin, so os.execute() isn't an option either.
It's odd that Microsoft make it so difficult to do in applications, even though File Explorer makes it so easy.
Moving or renaming the file (say by appending the current date/time) while testing is a practical workaround.
It's odd that Microsoft make it so difficult to do in applications, even though File Explorer makes it so easy.
Moving or renaming the file (say by appending the current date/time) while testing is a practical workaround.
Mark Draper