Click here to Skip to main content
15,885,925 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
Hi,

When I use Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) or Environment.GetFolderPath(Environment.SpecialFolder.Personal) on Windows XP it works great.

When I use these on Windows Vista it returns blank and puts files in my C:\Windows\System32 folder.

When I use these on Windows 7 it always returns C:\Users\dean\Documents.

The problem is I have redirected "My Documents" to drive F:\.
Does anyone know how to get the true (redirected) location of "My Documents" on Vista and 7? Any help appreciated!
Posted

You're after the Environment.SpecialFolder.MyDocuments enumeration. What do you mean by "redirected"?

According to the MSDN page, it should know how to retrieve folders that have been specified by the user.


Is it possible for you to try it using .Net 3.5 instead of 2.0?
 
Share this answer
 
v5
Comments
Dean Geddes 9-Jun-10 14:34pm    
Hi John,

Which Environment.SpecialFolder object? Neither Environment.SpecialFolder.MyDocuments nor Environment.SpecialFolder.Personal return the correct location on Windows Vista and 7. Im I missing something?

Cheers!
Dean
#realJSOP 9-Jun-10 14:39pm    
Can you try using .Net 3.5 instead of 2.0?
I guess I did not give enough information (though I didn't know that at the time). I was using these methods in my installer program. Windows Vista and 7 automatically run install programs as administrator which is why I got incorrect locations for MyDocuments and Personal.
Thanks for all assistance!
Dean
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900