". Net" C # Gets the path to the Windows System special folder

Source: Internet
Author: User

A System special folder is a folder that contains public information, such as "program Files", "Programs", "system", or "Startup". Special folders are set by default by the system, or are explicitly set by the user when installing a version of Windows.



Environment.getfolderpath method
Gets the path to the System special folder identified by the specified enumeration.





Namespaces: System
public static string GetFolderPath (SpecialFolder folder)





Parameters
Folder identifies the enumeration constants of the system's special folders. As follows:


The ApplicationData directory, which serves as the common repository for application-specific data for the current roaming user.
Roaming users work on more than one computer on the network. The roaming user's profile is saved on a network server and is loaded into the system when the user logs on to a system.


The Commonapplicationdata directory, which serves as a common repository for application-specific data that is used by all users.
CommonProgramFiles the directory for components that are shared among applications.
Cookies are used as directories for public repositories of Internet cookies.
Desktop logical desktops, not physical file system locations.
The desktopdirectory is used to physically store the directory of File objects on the desktop.
This directory should not be confused with the Desktop folder itself, which is a virtual folder.


Favorites a directory that serves as a common repository for user favorite items.
History the directory that is used as the public repository for Internet Chronicle items.
Internetcache is used as a directory for public repositories of temporary Internet files.
The Localapplicationdata directory, which serves as a common repository for application-specific data that is currently used by non-roaming users.
MyComputer the "My Computer" folder.
MyMusic the "My Music" folder.
MyPictures the "My Pictures" folder.
Personal the directory that is used as a common repository for documents.
ProgramFiles the "Program Files" directory.
Programs contains a directory of user program groups.
Recent The directory that contains the documents that the user has recently used.
SendTo the directory containing the Send menu item.
StartMenu the directory containing the Start menu item.
Startup directory that corresponds to the user's startup program group.
These programs are started every time a user logs on, starts Windows NT or later, or starts Windows 98 o'clock.


System "System" directory.
Templates a directory that is used as a common repository for document templates.





return value
If the special folder for the specified system actually exists on your computer, the path to the folder, otherwise an empty string (""). If the system does not create a folder, an existing folder is deleted, or the folder is a virtual directory that does not have a physical path (for example, My Computer), the folder does not actually exist.


Example:


String Path=environment.getfolderpath (Environment.SpecialFolder.Favorites);//return to favorite position

". Net" C # Gets the path to the Windows System special folder

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.