473,320 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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
mr*****@charter.net
My CSharp page: http://www.mag37.com/csharp/

Nov 15 '05 #1
8 8800
"Michael Mayer" <mr*****@charter.net> wrote in message
news:eU**************@TK2MSFTNGP09.phx.gbl...
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

Nov 15 '05 #2
string mydocs =
Environment.GetFolderPath(Environment.SpecialFolde r.Personal).ToString();
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.

Nov 15 '05 #3
"ghost" <ia******@hotmail.com> wrote in message
news:Vu********************@comcast.com...
string mydocs =

Environment.GetFolderPath(Environment.SpecialFolde r.Personal).ToString
();

excellent - that's even easier than reading the registry!
Nov 15 '05 #4
Its also better as the regkey may change and that API wont (well it may but
less likely than the reg) :D
"Michael Mayer" <mr*****@charter.net> wrote in message
news:en**************@tk2msftngp13.phx.gbl...
"ghost" <ia******@hotmail.com> wrote in message
news:Vu********************@comcast.com...
string mydocs =

Environment.GetFolderPath(Environment.SpecialFolde r.Personal).ToString
();

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

Nov 15 '05 #5
It also means you can change this ENV variable and it will point to the new
location easy too.
" Jack Meyhoff" <po********@127.0.0.10> wrote in message
news:uL*************@TK2MSFTNGP10.phx.gbl...
Its also better as the regkey may change and that API wont (well it may but less likely than the reg) :D
"Michael Mayer" <mr*****@charter.net> wrote in message
news:en**************@tk2msftngp13.phx.gbl...
"ghost" <ia******@hotmail.com> wrote in message
news:Vu********************@comcast.com...
string mydocs =

Environment.GetFolderPath(Environment.SpecialFolde r.Personal).ToString
();

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


Nov 15 '05 #6
It also means that you type it in differently, and it looks different too.

Jon
" Jack Meyhoff" <po********@127.0.0.10> wrote in message
news:uf**************@tk2msftngp13.phx.gbl...
It also means you can change this ENV variable and it will point to the new location easy too.
" Jack Meyhoff" <po********@127.0.0.10> wrote in message
news:uL*************@TK2MSFTNGP10.phx.gbl...
Its also better as the regkey may change and that API wont (well it may

but
less likely than the reg) :D
"Michael Mayer" <mr*****@charter.net> wrote in message
news:en**************@tk2msftngp13.phx.gbl...
"ghost" <ia******@hotmail.com> wrote in message
news:Vu********************@comcast.com...
> string mydocs =
>
Environment.GetFolderPath(Environment.SpecialFolde r.Personal).ToString
();

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



Nov 15 '05 #7
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/
mr*****@charter.net
"Jon Davis" <jo*@REMOVE.ME.PLEASE.jondavis.net> wrote in message
news:ud**************@TK2MSFTNGP12.phx.gbl...
It also means that you type it in differently, and it looks different too.

Jon
" Jack Meyhoff" <po********@127.0.0.10> wrote in message
news:uf**************@tk2msftngp13.phx.gbl...
It also means you can change this ENV variable and it will point to the

new
location easy too.
" Jack Meyhoff" <po********@127.0.0.10> wrote in message
news:uL*************@TK2MSFTNGP10.phx.gbl...
Its also better as the regkey may change and that API wont (well it may
but
less likely than the reg) :D
"Michael Mayer" <mr*****@charter.net> wrote in message
news:en**************@tk2msftngp13.phx.gbl...
> "ghost" <ia******@hotmail.com> wrote in message
> news:Vu********************@comcast.com...
> > string mydocs =
> >
>

Environment.GetFolderPath(Environment.SpecialFolde r.Personal).ToString > ();
>
> excellent - that's even easier than reading the registry!
>
>



Nov 15 '05 #8
"Michael Mayer" <mr*****@charter.net> wrote in message news:<uS*************@TK2MSFTNGP10.phx.gbl>...
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();"?

--
ale
http://www.sen.it
Nov 15 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Luca T. | last post by:
Hello, i need a way to find the home folder of the current user no matter if i am in Linux or Windows for instance: * Linux: /home/username * Windows: C:\Documents and Settings\username Is...
0
by: Alec Wysoker | last post by:
Could you explain a little more clearly what the problem is? In the implementation of expanduser in Python 2.3.4, it uses the value of HOME env var if it exists, otherwise, it uses HOMEDRIVE +...
22
by: Tony Houghton | last post by:
I'm using pygame to write a game called Bombz which needs to save some data in a directory associated with it. In Unix/Linux I'd probably use "~/.bombz", in Windows something like "C:\Documents...
4
by: jas | last post by:
I have a basic client/server socket situation setup....where the server accepts a connection and then waits for commands. On the client side, I create a socket, connect to the server...then I...
2
by: DBQueen | last post by:
I received a "Could Not Find Installable ISAM" error (#3170) when using Docmd.TransferDatabase to export a table from one database to another - Set wrkDefault = DBEngine.Workspaces(0)...
9
by: Dave Booker | last post by:
When I run a particular application I've been working on for a while, it somehow finds a value for the Application Setting "Test.Properties.Settings.Default.ProjectPath", but I can't see where it...
0
by: NSF12345 | last post by:
Iv developed a small program that looks for a file over our network, and copy it to the location of another computer. Im using the "If FileExists("\\oldpc\main share\Folder\file.txt") Then" way of...
1
ebs57
by: ebs57 | last post by:
This one is a bit tough (for me). I'm running a query that looks through two unrelated tables: One table contains an ID and the name of a training document while the other table contains an ID, an...
3
Chrisjc
by: Chrisjc | last post by:
So here is the issue at hand. I have several domains across a WAN environment and just recently I started noticing something odd between all my Domain Controllers. Every Site in my company has a...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.