-3

I have a 3 projects:

1 - .NET Core app

2 - .NET Framework app

3 - .NET Standard library where is common code for both first and second app projects.

...I want to check my drive free space in .NET Standard library to perform other following operations. Is it possible? How?

  • 2
    Please read the guidelines on how to ask a proper question. https://github.com/dotnet/corefx/issues/22660 https://stackoverflow.com/help/how-to-ask – Kieran Devlin Jan 09 '19 at 10:54

1 Answers1

2

DriveInfo is a system dependent InteropServices because the names and attributes of drives are different between Linux and Windows. But it is implemented in both worlds.

using System;
using System.IO;

//...

    DriveInfo[] allDrives = DriveInfo.GetDrives();

    foreach (DriveInfo d in allDrives)
    {
        Console.WriteLine("Drive {0}", d.Name);
        Console.WriteLine("  Free:{0, 15} bytes", d.AvailableFreeSpace);            
    }