Training
Module
Work with files and directories in a .NET app - Training
Learn how to use .NET, C#, and System.IO to work with directories, paths, files, and the file system.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
File associations define how the Shell treats a file type on the system.
This topic is organized as follows:
File associations control the following functionality:
Application developers can use file associations to control how the Shell treats custom file types, or to associate an application with existing file types. For example, when an application is installed, the application can check for the presence of existing file associations, and either create or override those file associations.
Users can control some aspects of file associations to customize how the Shell treats a file type either by using the Open With UI, or editing the registry.
In the Windows Explorer window shown in the screen shot below, the Shell displays different icons for each file, based on the icon associated with the file type. If the user double-clicks the file Sample Bitmap Image, the Shell launches Paint and uses it to open the file because on this system, Paint is associated with .bmp files. People can control these actions using file associations.
Applications can use files for various purposes: some files are used exclusively by the application, and are not typically accessed by users, while other files are created by the user and are often opened, searched for, and viewed from the Shell.
Unless your custom file type is used exclusively by the application, you should implement file associations for it. As a general rule, implement file associations for your custom file type if you expect the user to interact directly with these files in any way. That includes using the Shell to browse and open the files, searching the content or properties of the files, and previewing the files.
If your application is handling an existing file type, do not modify the file association unless you want to modify the way the Shell handles all files of this type.
Files are exposed in the Shell as Shell items. To control file associations, application developers can register a mapping between the file type and the handlers (COM objects that provide functionality for the file type's Shell items). When the Shell needs to query for the file associations of a file type, it creates an array of registry keys containing the associations for the file type, and checks these keys for the appropriate file associations to use.
Training
Module
Work with files and directories in a .NET app - Training
Learn how to use .NET, C#, and System.IO to work with directories, paths, files, and the file system.