How to get the original location of AppData\Roaming after the user has changed it?

Keywords: c# .net windows


I need to access contents in the folder %AppData%\Roaming\Microsoft.

This usually works fine by doing the following:

Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Microsoft");

The problem is that now the explorer lets you change the location of %AppData% by right clicking the Roaming folder and setting the location to some other place. However, this doesn't change the location of the Microsoft folder, which will remain in the original %AppData%.

I've thought about doing something like this:

string roaming = "C:\Users\" + Environment.UserName + @"\AppData\Roaming";

Though this just looks bad and looks like it could break easily. Any suggestions?