Reputation: 6581
My problem is pretty simple to explain but I cant seem to find out how to do it outside of windows/dotnet full. If there are two directories "/opt/data/" and "/opt/data2/" which are both mapped to different drives. How do I get information like free space and total space with just these two strings?
My first thought was to use the DriveInfo object in System.IO.FileSystem but it doesn't seem to be in the nuget package. Any Ideas?
Edit(important parts of csproj):
<TargetFramework>netcoreapp1.1</TargetFramework>
<PackageReference Include="System.IO.FileSystem" Version="4.3.0" />
Upvotes: 5
Views: 2918
Reputation: 6581
My issue could not be solved with just those two strings. I could only get the DriveInfo using the mount directory. For instance my main drive could only be fetched using '/'.
First add a dependency to the nuget package System.IO.FileSystem.DriveInfo
. Then you can use the DriveInfo package as shown below.
DriveInfo primaryDrive = new DriveInfo("/");
Upvotes: 2