CSharp - Write program to Get the Path to the Desktop

Requirements

When you work with files, you might want to create a file on the user's desktop.

find that path to the desktop.

Hint

You can use the Environment object.

The value of Desktop is one of the values of an enumeration called Environment.SpecialFolder.

Demo

using System;

class Program//from w w w  . j a  v a 2 s . c o  m
{
    static void Main(string[] args)
    {
        // Finding path to the desktop 
        string pathToDesktop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);

        // Output 
        Console.WriteLine("Path to your desktop: " + pathToDesktop);

    }
}

Result