WinNT: Delete to recycle bin?

Tino Lange tl_news at nexgo.de
Sat Jun 30 09:54:15 EDT 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.

Hallo John!

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:
http://de.geocities.com/tinolange/python/pywindel.zip

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)]
on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pywindel
>>> pywindel.DelToRecycleBin('t:\\foo.bar')
>>> print pywindel.LastStatus, pywindel.LastFile
0 t:\foo.bar
>>> ^Z
0. [199135k] t:\>

Remarks:

* 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!

Ciao
Tino



More information about the Python-list mailing list