tempfile.gettempdir() result on Windows
Tim Golden
tim.golden at viacom-outdoor.co.uk
Fri Jun 3 11:43:30 EDT 2005
[Leo Breebaart]
|
| On MS Windows, I am trying to find out a good default location to
| save some temporary files.
|
| The tempfile module seemed to have exactly what I wanted:
|
| >>> import tempfile
| >>> tempfile.gettempdir()
| 'c:\\docume~1\\admini~1\\locals~1\\temp'
| >>>
|
| My problem (entirely cosmetic, but still) is that I also need to
| show this location to the users of my program, who I suspect
| would be much happier with a 'proper' Windows path than with this
| '~1' DOS malarkey.
|
| Does anybody know how I can obtain a temp directory in 'verbose'
| format (or somehow convert the gettempdir() result to that)?
Have a look at win32api.GetLongPathName
(from the pywin32 extensions, in case it wasn't
obvious). So something like this:
<code>
import tempfile
import win32api
print tempfile.gettempdir ()
print win32api.GetLongPathName (tempfile.gettempdir ())
</code>
TJG
________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________
More information about the Python-list
mailing list