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
 
string mydocs =
Environment.GetFolderPath(Environment.SpecialFolder.Personal).ToString();
 
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.
 
It also means that you type it in differently, and it looks different too.

Jon
 
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();"?
 

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

Back
Top