WinNT: Delete to recycle bin?
tl_news at nexgo.de
Sat Jun 30 15:54:15 CEST 2001
On Fri, 29 Jun 2001 13:52:32 -0400 (EDT), you wrote:
>thanks so much!
>short of a python module, this is exactly what i'm looking for.
today I played a bit with my compiler and Python.
There must be a way to make the Recycler known to Python!
Here's a "working version" of a Python module - not perfect, but it
can do what you want:
In this archive you find the dll together with the source code - you
can modify it as you want and make it perfect for your application.
If you have Python 2.1 on your windows machine, just copy the
pywindel.dll in your (PYTHON)\DLLs - directory.
If you have another version of Python or if you want to change things
in the source code (I'm sure...) you have to re-compile the DLL with
MSVC6 (Project file included).
Example session in Python:
(you want to delete t:\foo.bar)
0. [211738k] t:\>python
ActivePython 2.1, build 210 ActiveState)
based on Python 2.1 (#15, Apr 23 2001, 18:00:35) [MSC 32 bit (Intel)]
Type "help", "copyright", "credits" or "license" for more information.
>>> import pywindel
>>> print pywindel.LastStatus, pywindel.LastFile
0. [199135k] t:\>
* LastStatus 0 means sucessfully deleted, 1 means no success.
You can always query this like above after a DelToRecycleBin call.
* You can only give _one_ file to pywindel.DelToRecycleBin().
This filename has to be the _complete_ Path, not a relative one (if
its relative, maybe the function will delete, but _not_ in the recycle
bin!) It only deletes to recycle bin if you give the complete path!
* You have to double \\ the backslashes like above.
For the last two points you can easily write apython wrapper that
preapares the DelToRecycleBin calls.
Hope this helps!
Have fun and a nice weekend!
More information about the Python-list