DiskInfoToolkit 2.1.4

dotnet add package DiskInfoToolkit --version 2.1.4
                    
NuGet\Install-Package DiskInfoToolkit -Version 2.1.4
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DiskInfoToolkit" Version="2.1.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DiskInfoToolkit" Version="2.1.4" />
                    
Directory.Packages.props
<PackageReference Include="DiskInfoToolkit" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DiskInfoToolkit --version 2.1.4
                    
#r "nuget: DiskInfoToolkit, 2.1.4"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DiskInfoToolkit@2.1.4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DiskInfoToolkit&version=2.1.4
                    
Install as a Cake Addin
#tool nuget:?package=DiskInfoToolkit&version=2.1.4
                    
Install as a Cake Tool

DiskInfoToolkit

GitHub license Build master Nuget Nuget

A toolkit for Storage Device informations. Primarily used for reading S.M.A.R.T. data from storage devices.

Preview of DiskInfoViewer

Please click on an image to show its full size.<br/> Note that the screenshots may not always represent the latest version of the app.

<a href="Screenshots/DiskInfoViewer01.png"> <img src="Screenshots/DiskInfoViewer01.png" width="300"/> </a> <a href="Screenshots/DiskInfoViewer02.png"> <img src="Screenshots/DiskInfoViewer02.png" width="300"/> </a>

Project overview

Project .NET Version[s]
DiskInfoToolkit <br/> This library reads detailed information from various types of storage devices - including NVMe, SSD, HDD and USB drives. <br/> It provides a high level API to read device data, SMART attributes, Partitions and other hardware details directly from the system. .NET Framework 4.7.2 & 4.8.1 <br/> .NET Standard 2.0 <br/> .NET 8, 9 and 10
ConsoleOutputTest <br/> Example Application to show how some library functionality can be used. .NET 8
DiskInfoViewer <br/> Visualization of detected storage devices on your system. <br/> This supports adding / removing storage devices and updates data. <br/> UI is built using Avalonia UI. .NET 8

What platforms are supported ?

We currently support Windows and Linux.<br/> There is currently no plan to support Mac / Apple Computers.

Where can I download it ?

You can download the latest release from here.

How can I help improve the project ?

Feel free to give feedback and contribute to our project !<br/> Pull requests are welcome. Please include as much information as possible.

Developer information

Integrate the library in your own application

Sample code

static class Program
{
    static void Main(string[] args)
    {
        //You can enable logging and set level, if you need logging output
        Logger.Instance.IsEnabled = true;
        Logger.Instance.LogLevel = LogLevel.Trace;

        //Get all storage devices
        var disks = Storage.GetDisks();

        //Go through all devices
        foreach (var disk in disks)
        {
            //Output Model of storage device
            Console.WriteLine($"Detected storage device '{disk.ProductName}' ('{disk.DisplayName}').");
        }

        //Register change event
        Storage.DevicesChanged += DevicesChanged;

        var secondsToWait = 10;

        //Wait for specified amount of time and listen to device changes
        Console.WriteLine($"Waiting {secondsToWait} seconds for device changes.");
        Thread.Sleep(TimeSpan.FromSeconds(secondsToWait));

        //Update devices once
        foreach (var disk in Storage.CurrentDisks)
        {
            //Refresh device data and output if there were changes compared to cached data
            if (Storage.Refresh(disk))
            {
                Console.WriteLine($"Refreshed - changes detected: '{disk.ProductName}' ('{disk.DisplayName}')");
            }
            else
            {
                Console.WriteLine($"Refreshed - no changes detected: '{disk.ProductName}' ('{disk.DisplayName}')");
            }
        }

        //Unregister change event
        Storage.DevicesChanged -= DevicesChanged;

        //Save log file to current directory, if you enabled logging output
        Logger.Instance.SaveToFile("Log.txt", false);

        //All done
        Console.WriteLine("Press enter to exit...");
        Console.ReadLine();
    }

    static void DevicesChanged(object sender, StorageDevicesChangedEventArgs e)
    {
        //Check if there are changes, if not we can ignore this event
        if (!e.HasChanges)
        {
            return;
        }

        //Simple output of added devices
        if (e.Added != null)
        {
            foreach (var added in e.Added)
            {
                Console.WriteLine($"Added: '{added.ProductName}' ('{added.DisplayName}')");
            }
        }

        //Simple output of removed devices
        if (e.Removed != null)
        {
            foreach (var removed in e.Removed)
            {
                Console.WriteLine($"Removed: '{removed.ProductName}' ('{removed.DisplayName}')");
            }
        }
    }
}

License

DiskInfoToolkit is free and open source software licensed under MPL 2.0.<br/> You can use it in private and commercial projects.<br/> Keep in mind that you must include a copy of the license in your project.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core