This will create a folder named "MyName" in "%appdata%".
string directoryName = "MyName";
string appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
string mainPath = Path.Combine(appDataPath, directoryName);
Directory.CreateDirectory(mainPath);
This will create a file in "%appdata%" called "MyFile.txt" which says "Hello World".
string text = "Hello Word";
string fileName = "MyFile.txt";
string appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
string mainPath = Path.Combine(appDataPath, fileName);
File.WriteAllText(mainPath, text);