Skip to main content
Total Downloads
568
568
Published
Oct 19, 2026
4d ago

Get Started

dotnet add package XFiler.FileOperations.Windows --version 10.0.1
ProductVersions
.NET
net10.0-windows7.0

README

FileOperations

CI License: MIT

Platform-native file operations for .NET 10 desktop apps: move to Recycle Bin / Trash, well-known user folders, logical drives and drive mount notifications β€” behind one set of interfaces for Windows and macOS. Used by the X-Filer file manager.

Package Target Version Downloads
XFiler.FileOperations.Abstractions net10.0 NuGet Downloads
XFiler.FileOperations.Windows net10.0-windows NuGet Downloads
XFiler.FileOperations.Mac net10.0-macos NuGet Downloads
Egorozh.Windows.ImageOperations net10.0-windows NuGet Downloads

What is inside

Interface (Abstractions) Windows macOS
IFileOperations β€” delete a file or folder permanently or to the Recycle Bin / Trash, list logical drives WindowsFileOperations (Shell SHFileOperation) MacOsFileOperations (NSFileManager.TrashItem, mounted volumes)
IPlatformFolders β€” app data, Desktop, Downloads, Documents, Movies, Music, Pictures WindowsPlatformFolders MacOsPlatformFolders
IDriveDetector β€” DriveChanged event when a drive is added or removed WindowsDriveDetector (WMI Win32_VolumeChangeEvent) MacOsDriveDetector (NSWorkspace mount/unmount notifications; IDisposable)

WindowsFileOperations also has static helpers that go through the Windows Shell with its own progress and confirmation UI: CopyFile/CopyFiles/CopyDirectory, MoveFile/MoveFiles/MoveDirectory, DeleteFile/DeleteFiles/DeleteDirectory and Rename*.

Egorozh.Windows.ImageOperations extracts the Shell icon of a file (ImageSystem.GetIcon, ImageSystem.GetIconStream).

Install

Reference the abstractions from shared code and the platform package from the app head:

<ItemGroup>
  <PackageReference Include="XFiler.FileOperations.Abstractions" Version="10.0.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net10.0-windows'">
  <PackageReference Include="XFiler.FileOperations.Windows" Version="10.0.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net10.0-macos'">
  <PackageReference Include="XFiler.FileOperations.Mac" Version="10.0.0" />
</ItemGroup>

The Windows package targets net10.0-windows, so a plain net10.0 project cannot reference it β€” the Windows head of the app has to target net10.0-windows too. The Mac package needs the macos workload (dotnet workload install macos).

Usage

using FileOperations.Abstractions;
using FileOperations.Abstractions.Enums;
#if MACOS
using FileOperations.MacOs;
#else
using FileOperations.Windows;
#endif

#if MACOS
IFileOperations fileOperations = new MacOsFileOperations();
IPlatformFolders folders = new MacOsPlatformFolders();
#else
IFileOperations fileOperations = new WindowsFileOperations();
IPlatformFolders folders = new WindowsPlatformFolders();
#endif

// Recycle Bin on Windows, Trash on macOS; throws if the item cannot be moved there.
fileOperations.DeleteFile(path, RecycleOption.SendToRecycleBin);
fileOperations.DeleteDirectory(folder, DeleteDirectoryOption.DeleteAllContents, RecycleOption.SendToRecycleBin);

string settingsFolder = Path.Combine(folders.GetAppDataPath(), "MyApp");

Watch for drives being plugged in or ejected:

#if MACOS
IDriveDetector detector = new MacOsDriveDetector();
#else
IDriveDetector detector = new WindowsDriveDetector();
#endif

detector.DriveChanged += (type, drive) => Console.WriteLine($"{type}: {drive}");

All packages are marked AOT-compatible.

Build

cd src
dotnet build FileOperations.sln

EnableWindowsTargeting is on, so the Windows projects also build on macOS and Linux (they only run on Windows). Building the Mac project needs macOS with Xcode and the macos workload.

Release

CI (.github/workflows/ci.yml) builds and packs the Windows packages on a Windows runner and the Mac package on a macOS runner, on every push and pull request to main. Pushing a v* tag publishes all packages to NuGet.org with the version taken from the tag (v10.0.1 β†’ 10.0.1) through NuGet Trusted Publishing β€” no API key: a nuget.org trusted publishing policy for this repository and ci.yml, and the NUGET_USER repository secret (nuget.org profile name of the policy's creator).

git tag v10.0.1
git push origin v10.0.1

Changelog

10.0.0

  • Targets .NET 10: net10.0 (Abstractions), net10.0-windows (Windows, ImageOperations), net10.0-macos (Mac).
  • macOS: moving to Trash throws an IOException when it fails instead of silently doing nothing.
  • macOS: MacOsDriveDetector reports mounted and unmounted volumes (it was an empty stub).

8.0.0 β€” first release, .NET 8.

License

MIT

Downloads by Version

Similar & Alternative Packages

Hand-picked matching NuGet libraries based on tags & ecosystem

Depended On By

Find packages that declare this package as a dependency. NuGet does not provide a reverse-dependency endpoint, so candidates are checked on demand.

Adoption Assessment

Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.

No SPDX license expression is published. Review the license text and your organisation's policy before redistribution.Compatibility metadata lists 1 target framework; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.