Connecting Tech Pros Worldwide Forums | Help | Site Map

finding user's My Documents

Michael Mayer
Guest
 
Posts: n/a
#1: Nov 15 '05
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
mrmayer@charter.net
My CSharp page: http://www.mag37.com/csharp/




Michael Mayer
Guest
 
Posts: n/a
#2: Nov 15 '05

re: finding user's My Documents


"Michael Mayer" <mrmayer@charter.net> wrote in message
news:eUr5IL7YDHA.2648@TK2MSFTNGP09.phx.gbl...[color=blue]
> 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[/color]
namespace[color=blue]
> in .NET to assist with this? Or must I use P/Invoke - if so,[/color]
anybody[color=blue]
> know the correct dll / function?
>
> Thanks in advance - my google searches aren't turning up anything.[/color]


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
Guest
 
Posts: n/a
#3: Nov 15 '05

re: finding user's My Documents


string mydocs =
Environment.GetFolderPath(Environment.SpecialFolde r.Personal).ToString();
[color=blue]
> 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.
>[/color]


Michael Mayer
Guest
 
Posts: n/a
#4: Nov 15 '05

re: finding user's My Documents


"ghost" <iam_bkee@hotmail.com> wrote in message
news:VuacnSUcrueLXqCiXTWJkA@comcast.com...[color=blue]
> string mydocs =
>[/color]
Environment.GetFolderPath(Environment.SpecialFolde r.Personal).ToString
();

excellent - that's even easier than reading the registry!


Jack Meyhoff
Guest
 
Posts: n/a
#5: Nov 15 '05

re: finding user's My Documents


Its also better as the regkey may change and that API wont (well it may but
less likely than the reg) :D


"Michael Mayer" <mrmayer@charter.net> wrote in message
news:enC9wS8YDHA.2476@tk2msftngp13.phx.gbl...[color=blue]
> "ghost" <iam_bkee@hotmail.com> wrote in message
> news:VuacnSUcrueLXqCiXTWJkA@comcast.com...[color=green]
> > string mydocs =
> >[/color]
> Environment.GetFolderPath(Environment.SpecialFolde r.Personal).ToString
> ();
>
> excellent - that's even easier than reading the registry!
>
>[/color]


Jack Meyhoff
Guest
 
Posts: n/a
#6: Nov 15 '05

re: finding user's My Documents


It also means you can change this ENV variable and it will point to the new
location easy too.


" Jack Meyhoff" <postmaster@127.0.0.10> wrote in message
news:uLvbQP9YDHA.388@TK2MSFTNGP10.phx.gbl...[color=blue]
> Its also better as the regkey may change and that API wont (well it may[/color]
but[color=blue]
> less likely than the reg) :D
>
>
> "Michael Mayer" <mrmayer@charter.net> wrote in message
> news:enC9wS8YDHA.2476@tk2msftngp13.phx.gbl...[color=green]
> > "ghost" <iam_bkee@hotmail.com> wrote in message
> > news:VuacnSUcrueLXqCiXTWJkA@comcast.com...[color=darkred]
> > > string mydocs =
> > >[/color]
> > Environment.GetFolderPath(Environment.SpecialFolde r.Personal).ToString
> > ();
> >
> > excellent - that's even easier than reading the registry!
> >
> >[/color]
>
>[/color]


Jon Davis
Guest
 
Posts: n/a
#7: Nov 15 '05

re: finding user's My Documents


It also means that you type it in differently, and it looks different too.

Jon


" Jack Meyhoff" <postmaster@127.0.0.10> wrote in message
news:ufjlPR9YDHA.2476@tk2msftngp13.phx.gbl...[color=blue]
> It also means you can change this ENV variable and it will point to the[/color]
new[color=blue]
> location easy too.
>
>
> " Jack Meyhoff" <postmaster@127.0.0.10> wrote in message
> news:uLvbQP9YDHA.388@TK2MSFTNGP10.phx.gbl...[color=green]
> > Its also better as the regkey may change and that API wont (well it may[/color]
> but[color=green]
> > less likely than the reg) :D
> >
> >
> > "Michael Mayer" <mrmayer@charter.net> wrote in message
> > news:enC9wS8YDHA.2476@tk2msftngp13.phx.gbl...[color=darkred]
> > > "ghost" <iam_bkee@hotmail.com> wrote in message
> > > news:VuacnSUcrueLXqCiXTWJkA@comcast.com...
> > > > string mydocs =
> > > >
> > > Environment.GetFolderPath(Environment.SpecialFolde r.Personal).ToString
> > > ();
> > >
> > > excellent - that's even easier than reading the registry!
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


Michael Mayer
Guest
 
Posts: n/a
#8: Nov 15 '05

re: finding user's My Documents


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.

--
Mike Mayer
http://www.mag37.com/csharp/
mrmayer@charter.net


"Jon Davis" <jon@REMOVE.ME.PLEASE.jondavis.net> wrote in message
news:udMbtJFZDHA.1748@TK2MSFTNGP12.phx.gbl...[color=blue]
> It also means that you type it in differently, and it looks different too.
>
> Jon
>
>
> " Jack Meyhoff" <postmaster@127.0.0.10> wrote in message
> news:ufjlPR9YDHA.2476@tk2msftngp13.phx.gbl...[color=green]
> > It also means you can change this ENV variable and it will point to the[/color]
> new[color=green]
> > location easy too.
> >
> >
> > " Jack Meyhoff" <postmaster@127.0.0.10> wrote in message
> > news:uLvbQP9YDHA.388@TK2MSFTNGP10.phx.gbl...[color=darkred]
> > > Its also better as the regkey may change and that API wont (well it[/color][/color][/color]
may[color=blue][color=green]
> > but[color=darkred]
> > > less likely than the reg) :D
> > >
> > >
> > > "Michael Mayer" <mrmayer@charter.net> wrote in message
> > > news:enC9wS8YDHA.2476@tk2msftngp13.phx.gbl...
> > > > "ghost" <iam_bkee@hotmail.com> wrote in message
> > > > news:VuacnSUcrueLXqCiXTWJkA@comcast.com...
> > > > > string mydocs =
> > > > >
> > > >[/color][/color][/color]
Environment.GetFolderPath(Environment.SpecialFolde r.Personal).ToString[color=blue][color=green][color=darkred]
> > > > ();
> > > >
> > > > excellent - that's even easier than reading the registry!
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


Alessandro Riolo
Guest
 
Posts: n/a
#9: Nov 15 '05

re: finding user's My Documents


"Michael Mayer" <mrmayer@charter.net> wrote in message news:<uSv2LzbZDHA.652@TK2MSFTNGP10.phx.gbl>...[color=blue]
> 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).[/color]


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

--
ale
http://www.sen.it
Closed Thread