c# get user root directory from windows service
I have a Windows Service written in C#. I need to add a file to each user
directory. How can I find the path to start in? I realize this is really
dumb but this is what I'm currently doing:
if (Directory.Exists("C:\\Users"))
{
path = "C:\\Users";
}
else if (Directory.Exists("C:\\Documents and Settings"))
{
path = "C:\\Documents and Settings";
}
I've looked at the special folders:
http://msdn.microsoft.com/en-us/library/system.environment.specialfolder.aspx
None of them seem to return what I need. For example, ApplicationData is
returning the path to the System32 directory. I presume this is because it
is running as a windows service. The code I'm currently using works for
the few tests I've done. It just seems like there should be a more
intelligent (error proof) way of getting this path.
No comments:
Post a Comment