[python-win32] AppData directory on Windows?
mail at timgolden.me.uk
Thu Sep 1 14:49:02 CEST 2011
On 01/09/2011 13:39, Kevin Walzer wrote:
> I’m getting feedback from a Windows user that says my Tkinter app won’t
> write data to an app temporary directory. Here’s my code:
> sys.stderr=open(os.path.join(os.path.expanduser('~'), 'Application
> Data', 'QuickWho', 'QuickWho_errors.txt'), 'w')
This is a little brittle. I imagine it will at least break
from non-English versions of Windows. It will also break
for versions of Python prior to 2.5? when expanduser was
expanded to include Windows.
The simplest approach is to use the APPDATA env var which
goes back a few versions (certainly to XP, probably Win 2000).
Alternatively, you can use the Windows Shell API to query the
same thing -- this should go back even further if you've got
someone using something truly prehistoric.
More information about the python-win32