os.unlink() AND win32api.DeleteFile()

Tim Roberts timr at probo.com
Tue Jan 24 03:04:04 EST 2006


rbt <rbt at athop1.ath.vt.edu> wrote:
>
>Can someone detail the differences between these two? On Windows which 
>is preferred?

os.unlink() calls unlink() in the C run-time library.  In VC++, unlink()
passes its parameter directly to DeleteFile.  There is no difference.
DeleteFile() is the only way to delete files on Windows.

However, if you call os.unlink(), your script will ALSO work in Linux.
win32api.DeleteFile() makes your script Windows-only.

>Also, is it true that win32api.DeleteFile() can remove the 'special' 
>files located in the 'special' folders only accessible by the shell 
>object such as Temporary Internet Files, etc.

"Temporary Internet Files" is a perfectly normal directory, living at
"\Documents and Settings\username\Local Settings\Temporary Internet Files".
It happens to be marked with the "system" attribute ('attrib +s'), but that
doesn't make it special.

Now, there certainly ARE special shell folders that do not exist in the
file system.  Control Panel and My Network Places are two examples.
DeleteFile cannot touch those.  You must use shell APIs.
-- 
- Tim Roberts, timr at probo.com
  Providenza & Boekelheide, Inc.



More information about the Python-list mailing list