mwpeck
May 29th, 2008, 08:37 PM
Whats the best way to find the default user directory of the person logged into a computer?
|
Click to See Complete Forum and Search --> : [RESOLVED] Find a default user directory mwpeck May 29th, 2008, 08:37 PM Whats the best way to find the default user directory of the person logged into a computer? boudino May 30th, 2008, 02:52 AM Try Environment.GetFolderPath() method. Exact value of Environment.GetFolderPath SpecialFolder enumeration you'll have to choose yourself. mwpeck May 30th, 2008, 03:27 AM Yeah I found a solution after digging more into it. Arjay May 30th, 2008, 03:32 AM Please post the solution so that others may benefit. mwpeck May 30th, 2008, 03:46 AM Environment.GetEnvironmentVariable("APPDATA"); That returns the location where applications store data by default (such as c:\users\<name>\roaming in Vista64) List of all the variables here: http://libertyboy.free.fr/computing/reference/envariables/index.php Just use the variable name without the %'s. boudino May 30th, 2008, 03:58 AM That's great news. But the next time, please write it to the post that others can find out that the solution was already found. Arjay May 30th, 2008, 12:07 PM Environment.GetEnvironmentVariable("APPDATA"); That returns the location where applications store data by default (such as c:\users\<name>\roaming in Vista64) List of all the variables here: http://libertyboy.free.fr/computing/reference/envariables/index.php Just use the variable name without the %'s.I don't want to sound like I'm harping on you, but the environment variables should be a last resort approach. Instead prefer to use a class that delivers this data to you (such as the SpecialFolder enum approach that Boudino suggested). Getting things out of the registry or from environment variables is fragile and isn't guaranteed to be the same from OS version to OS version. MS does their best to ensure forward compatibility within the api set, but doesn't make the same guarantee for registry settings and environment variables. It might seem like a little thing, but it's one thing less that can go wrong when you run your app on a newer OS. mwpeck May 30th, 2008, 12:19 PM For my uses currently I'm not worried about my app not working in a newer OS...but I will take note of it for future apps. codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |