What is a shortcut to the Default home directory in Windows

D

Daniel Folkes

I am trying to write a file to the users file system.

I need it to be in there home directory in WINDOWS. I know there is a
"shortcut" to home in Linux("~"), but is there an equivalent to that
in windows. Or to get to their "Documents and Settings" directory?

Thanks in advance for the help.

-Daniel Folkes
 
C

Christian Heimes

Daniel said:
I am trying to write a file to the users file system.

I need it to be in there home directory in WINDOWS. I know there is a
"shortcut" to home in Linux("~"), but is there an equivalent to that
in windows. Or to get to their "Documents and Settings" directory?

Thanks in advance for the help.

os.path.expanduser("~") works on Windows, too. For application related
data like config files please use os.environ["APPDATA"]. For all
remaining shell folders like My Documents you *have* to use the win32
api. All shell folder names are localized and depend on the language
version.

Christian
 
J

Jerry Hill

I am trying to write a file to the users file system.

I need it to be in there home directory in WINDOWS. I know there is a
"shortcut" to home in Linux("~"), but is there an equivalent to that
in windows. Or to get to their "Documents and Settings" directory?

The easiest way is os.path.expanduser('~')

That works on both unix and windows. It gets you the user's home
directory on unix, and on windows I think it is based on the
environment variables %HOMEDRIVE% and %HOMEPATH%. If that doesn't
give you what you're looking for, you'll need to look into the
environment variables, the registry, or windows system calls,
depending on exactly what you need.
 
M

Mike Driscoll

I am trying to write a file to the users file system.

I need it to be in there home directory in WINDOWS. I know there is a
"shortcut" to home in Linux("~"), but is there an equivalent to that
in windows. Or to get to their "Documents and Settings" directory?

Thanks in advance for the help.

-Daniel Folkes

I personally use Tim Golden's excellent win32 API wrapper, the
winshell script. You can find it here:

http://timgolden.me.uk/python/winshell.html

Mike
 
T

Tim Golden

Christian said:
Yeah. Tim's winshell is fine but it's not using the official win32 api.

Umm... Is it not? The only thing I'm aware of doing is
retaining backwards compat. by using SHGetPathFromIDList
on the SHGetSpecialFolderLocation because I was writing against
Win9x at the time. Or are you saying something else?

(Admit I haven't checked all the docs since I wrote it
to see what's been "deprecated" this week).

TJG
 
C

Christian Heimes

Tim said:
Umm... Is it not? The only thing I'm aware of doing is
retaining backwards compat. by using SHGetPathFromIDList
on the SHGetSpecialFolderLocation because I was writing against
Win9x at the time. Or are you saying something else?

(Admit I haven't checked all the docs since I wrote it
to see what's been "deprecated" this week).

A lot has been deprecated :(
MS has deprecated all functions which are using CSIDL and introduced a
new stack for Vista.

Christian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top