C# library and .NET tool for managing file extension associations on Windows 10/11.
Easily set or remove default applications for specific file extensions programmatically, with full registry integration.
This repo contains both a C# library and a .NET tool for managing file extension associations on Windows 10/11.
The library allows developers to programmatically set, remove, and check file associations, while the tool provides a command-line interface for performing these actions.
Both packages can be found on NuGet.org and GitHub Packages
dotnet add package dotnet-file-associatorusing DotnetFileAssociator;
// Associates ".abc" files with MyApp.exe.
FileAssociator.SetFileAssociation(
@"C:\Program Files\MyApp\MyApp.exe",
".abc"
);using DotnetFileAssociator;
// Removes the association between ".abc" files and MyApp.exe.
FileAssociator.RemoveFileAssociation(
@"C:\Program Files\MyApp\MyApp.exe",
".abc"
);using DotnetFileAssociator;
// Checks if MyApp.exe has been previously associated with ".abc" files.
FileAssociator.IsFileAssociationSet(
@"C:\Program Files\MyApp\MyApp.exe",
".abc"
);Install the .NET tool (optionally globally) using the following command:
dotnet tool install dotnet-file-associator.tool -gIt can then be invoked such as:
dotnet dotnet-file-associator --versionor the long version:
dotnet tool run dotnet-file-associator --helpdotnet dotnet-file-associator set -p "C:\Program Files\MyApp\MyApp.exe" -e ".abc"dotnet dotnet-file-associator remove -p "C:\Program Files\MyApp\MyApp.exe" -e ".abc"dotnet dotnet-file-associator check -p "C:\Program Files\MyApp\MyApp.exe" -e ".abc"Status code 0 is returned if the association exists, otherwise 1 is returned.