finding user's My Documents

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michael Mayer

    #1

    finding user's My Documents

    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

    #2
    Re: finding user's My Documents

    "Michael Mayer" <mrmayer@charte r.net> wrote in message
    news:eUr5IL7YDH A.2648@TK2MSFTN GP09.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_US ER:
    Software\Micros oft\Windows\Cur rentVersion\Exp lorer\Shell Folders



    Comment

    • ghost

      #3
      Re: finding user's My Documents

      string mydocs =
      Environment.Get FolderPath(Envi ronment.Special Folder.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]


      Comment

      • Michael Mayer

        #4
        Re: finding user's My Documents

        "ghost" <iam_bkee@hotma il.com> wrote in message
        news:VuacnSUcru eLXqCiXTWJkA@co mcast.com...[color=blue]
        > string mydocs =
        >[/color]
        Environment.Get FolderPath(Envi ronment.Special Folder.Personal ).ToString
        ();

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


        Comment

        • Jack Meyhoff

          #5
          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@charte r.net> wrote in message
          news:enC9wS8YDH A.2476@tk2msftn gp13.phx.gbl...[color=blue]
          > "ghost" <iam_bkee@hotma il.com> wrote in message
          > news:VuacnSUcru eLXqCiXTWJkA@co mcast.com...[color=green]
          > > string mydocs =
          > >[/color]
          > Environment.Get FolderPath(Envi ronment.Special Folder.Personal ).ToString
          > ();
          >
          > excellent - that's even easier than reading the registry!
          >
          >[/color]


          Comment

          • Jack Meyhoff

            #6
            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:uLvbQP9YDH A.388@TK2MSFTNG P10.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@charte r.net> wrote in message
            > news:enC9wS8YDH A.2476@tk2msftn gp13.phx.gbl...[color=green]
            > > "ghost" <iam_bkee@hotma il.com> wrote in message
            > > news:VuacnSUcru eLXqCiXTWJkA@co mcast.com...[color=darkred]
            > > > string mydocs =
            > > >[/color]
            > > Environment.Get FolderPath(Envi ronment.Special Folder.Personal ).ToString
            > > ();
            > >
            > > excellent - that's even easier than reading the registry!
            > >
            > >[/color]
            >
            >[/color]


            Comment

            • Jon Davis

              #7
              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:ufjlPR9YDH A.2476@tk2msftn gp13.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:uLvbQP9YDH A.388@TK2MSFTNG P10.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@charte r.net> wrote in message
              > > news:enC9wS8YDH A.2476@tk2msftn gp13.phx.gbl...[color=darkred]
              > > > "ghost" <iam_bkee@hotma il.com> wrote in message
              > > > news:VuacnSUcru eLXqCiXTWJkA@co mcast.com...
              > > > > string mydocs =
              > > > >
              > > > Environment.Get FolderPath(Envi ronment.Special Folder.Personal ).ToString
              > > > ();
              > > >
              > > > excellent - that's even easier than reading the registry!
              > > >
              > > >[/color]
              > >
              > >[/color]
              >
              >[/color]


              Comment

              • Michael Mayer

                #8
                Re: finding user's My Documents

                I've been offline trying to re-image my machine. Ugh.

                While I prefer the Environment.Get FolderPath, 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.Get FolderPath 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

                mrmayer@charter .net


                "Jon Davis" <jon@REMOVE.ME. PLEASE.jondavis .net> wrote in message
                news:udMbtJFZDH A.1748@TK2MSFTN GP12.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:ufjlPR9YDH A.2476@tk2msftn gp13.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:uLvbQP9YDH A.388@TK2MSFTNG P10.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@charte r.net> wrote in message
                > > > news:enC9wS8YDH A.2476@tk2msftn gp13.phx.gbl...
                > > > > "ghost" <iam_bkee@hotma il.com> wrote in message
                > > > > news:VuacnSUcru eLXqCiXTWJkA@co mcast.com...
                > > > > > string mydocs =
                > > > > >
                > > > >[/color][/color][/color]
                Environment.Get FolderPath(Envi ronment.Special Folder.Personal ).ToString[color=blue][color=green][color=darkred]
                > > > > ();
                > > > >
                > > > > excellent - that's even easier than reading the registry!
                > > > >
                > > > >
                > > >
                > > >[/color]
                > >
                > >[/color]
                >
                >[/color]


                Comment

                • Alessandro Riolo

                  #9
                  Re: finding user's My Documents

                  "Michael Mayer" <mrmayer@charte r.net> wrote in message news:<uSv2LzbZD HA.652@TK2MSFTN GP10.phx.gbl>.. .[color=blue]
                  > I've been offline trying to re-image my machine. Ugh.
                  >
                  > While I prefer the Environment.Get FolderPath, 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.Get FolderPathEnvir onment.SpecialF older.MyPicture s).ToString();" ?

                  --
                  ale

                  Comment

                  Working...