Skip to content

mukunku/dotnet-file-associator

Repository files navigation

dotnet-file-associator

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.

Description

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

C# Library NuGet version

How to Install

dotnet add package dotnet-file-associator

Example Usages

Set file association:

using DotnetFileAssociator;

// Associates ".abc" files with MyApp.exe.
FileAssociator.SetFileAssociation(
    @"C:\Program Files\MyApp\MyApp.exe",
    ".abc"
);

Remove file association:

using DotnetFileAssociator;

// Removes the association between ".abc" files and MyApp.exe.
FileAssociator.RemoveFileAssociation(
    @"C:\Program Files\MyApp\MyApp.exe",
    ".abc"
);

Check file association:

using DotnetFileAssociator;

// Checks if MyApp.exe has been previously associated with ".abc" files.
FileAssociator.IsFileAssociationSet(
    @"C:\Program Files\MyApp\MyApp.exe",
    ".abc"
);

.NET Tool NuGet version

How to Install

Install the .NET tool (optionally globally) using the following command:

dotnet tool install dotnet-file-associator.tool -g

It can then be invoked such as:

dotnet dotnet-file-associator --version

or the long version:

dotnet tool run dotnet-file-associator --help

Example Usages

Set file association:

dotnet dotnet-file-associator set -p "C:\Program Files\MyApp\MyApp.exe" -e ".abc"

Remove file association:

dotnet dotnet-file-associator remove -p "C:\Program Files\MyApp\MyApp.exe" -e ".abc"

Check file association:

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.

About

C# library and .NET tool for managing file extension associations on Windows 10/11.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages