Using class System.Environment you can get paths of special Windows folders such as Program Files, My Documents and others. The list of available values is stored in enum object Environment.SpecialFolder (Fugure 1).

Figure 1. Available values of Environment.SpecialFolder object

Figure 1. Available values of Environment.SpecialFolder object

 

The code for receiving and using of My Documents folder path is below. The program writes file in My Documents folder and reads it.

        static void Main(string[] args)
        {
            string myDocuments = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            string filename = Path.Combine(myDocuments, "helloworld.txt");
            File.WriteAllText(filename, "Hello world");

            string content = File.ReadAllText(filename);
            Console.WriteLine(content);
        }