Most operating systems have a bunch of well-known filesystem locations, and Windows is no exception. There are designated folders for things like the current user’s documents, pictures, or desktop; the program files directory where applications are installed; and the system folder.
The .NET Framework provides a class called
Environment that provides information about the
world our program runs in. Its static method
GetFolderPath is the one that interests us right
now, because it will return the path of various well-known folders. We
pass it one of the
enumeration values. Example 11-13 retrieves the location
of one of the folders in which applications can store per-user
Example 11-13. Getting a well-known folder location
string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
Table 11-4 lists all of the well-known
GetFolderPath can return,
and the location they give on the installed copy of Windows 7 (64-bit)
belonging to one of the authors.
Table 11-4. Special folders
A place for applications to store their own private information for a particular user; this may be located on a shared server, and available across multiple logins for the same user, on different machines, if the user’s domain policy is configured to do so.
A place for applications to store their own private information ...