Home >Backend Development >C++ >How Do I Get the Desktop Path in C#?

How Do I Get the Desktop Path in C#?

Barbara Streisand
Barbara StreisandOriginal
2025-01-01 06:32:17497browse

How Do I Get the Desktop Path in C#?

Obtaining the Desktop Path in C#

In C#, one can retrieve the path to the desktop of the current user with the Environment.GetFolderPath method. This method takes an argument specifying which special folder to retrieve the path for.

To obtain the desktop path, pass Environment.SpecialFolder.Desktop as the argument:

string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);

This will assign the path to the current user's desktop to the path variable.

The above is the detailed content of How Do I Get the Desktop Path in C#?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn