You're trying to access the enumeration value LocalApplicationData
as if it were a string. It's not. You need to find the folder path with GetFolderPath
:
string path = Environment.GetFolderPath(
System.Environment.SpecialFolder.LocalApplicationData);
Incidentally, it's better form, and less error-prone, to use Path.Combine
to build up paths, rather than doing it by hand:
string path = Path.Combine(@"C:\", "dir"); // gives you "C:\dir"
...and so your code would end up looking like:
string appDataPath = Environment.GetFolderPath
(System.Environment.SpecialFolder.LocalApplicationData);
string path = Path.Combine(appDataPath, "MyProgram");
Directory.CreateDirectory(path);