Environment.GetFolderPath(...CommonApplicationData) is still returning c:\Docs&Set on Vista
Posted
by blak3r
on Stack Overflow
See other posts from Stack Overflow
or by blak3r
Published on 2009-05-21T23:09:11Z
Indexed on
2010/06/08
19:02 UTC
Read the original article
Hit count: 131
As i understand it, you're supposed to use Environment.GetFolderPath method so you have OS independent code...
WinXP uses C:\Docs and Settings\ Vista uses C:\ProgramData and c:\Users
I'm using the code below on a vista computer and it's returning a c:\documents and settings directory instead of c:\ProgramData like it should... Any ideas?
string commonAppData = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
try
{
File.CreateText( Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\mycompany\\uid");
log.Debug("Created file successfully");
}
catch (Exception ex)
{
log.Error("Unable to create the uid file: ", ex);
}
EDIT: I was mistaken... See my answer below. Please vote to close this post as it's no longer relevent.
© Stack Overflow or respective owner