finding user's My Documents

  • Thread starter Thread starter Michael Mayer
  • Start date Start date
M

Michael Mayer

I have a windows forms app and am wondering how I find the My
Document's folder of the current user. Is there a class or namespace
in .NET to assist with this? Or must I use P/Invoke - if so, anybody
know the correct dll / function?

Thanks in advance - my google searches aren't turning up anything.
 
Michael Mayer said:
I have a windows forms app and am wondering how I find the My
Document's folder of the current user. Is there a class or namespace
in .NET to assist with this? Or must I use P/Invoke - if so, anybody
know the correct dll / function?

Thanks in advance - my google searches aren't turning up anything.


Just im'ing with a friend and he reminded me it's a registry setting.
To be specific:
HKEY_CURRENT_USER:
Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
 
ghost said:
string mydocs =
Environment.GetFolderPath(Environment.SpecialFolder.Personal).ToString
();

excellent - that's even easier than reading the registry!
 
Its also better as the regkey may change and that API wont (well it may but
less likely than the reg) :D
 
It also means you can change this ENV variable and it will point to the new
location easy too.
 
I've been offline trying to re-image my machine. Ugh.

While I prefer the Environment.GetFolderPath, it turns out that doesn't work
for me. I really want the folder of My Pictures, which doesn't have to be
under My Documents (so I guess I asked the wrong question). A registry key
points to it exactly, while the Environment.GetFolderPath doesn't have an
entry for Pictures.

But I'll certainly use the GetFolderPath when I can. Didn't realize all the
stuff Environment provides.
 
Michael Mayer said:
I've been offline trying to re-image my machine. Ugh.

While I prefer the Environment.GetFolderPath, it turns out that doesn't work
for me. I really want the folder of My Pictures, which doesn't have to be
under My Documents (so I guess I asked the wrong question).


What about "string mydocs =
Environment.GetFolderPathEnvironment.SpecialFolder.MyPictures).ToString();"?
 
Back
Top