Asp.net core .Net Core 2.1 System.IO.FileSystem.DriveInfo
我有一个使用Visual Studio 2017 Preview 4的.NET Core 2.1控制台应用程序 我似乎无法将System.IO.FileSystem引入到我的项目中。我需要访问TotalFreeSpace 我有:Asp.net core .Net Core 2.1 System.IO.FileSystem.DriveInfo,asp.net-core,.net-core,asp.net-core-2.1,.net-core-2.1,Asp.net Core,.net Core,Asp.net Core 2.1,.net Core 2.1,我有一个使用Visual Studio 2017 Preview 4的.NET Core 2.1控制台应用程序 我似乎无法将System.IO.FileSystem引入到我的项目中。我需要访问TotalFreeSpace 我有: dotnet add package System.IO.FileSystem.DriveInfo 成功无误 在我的.csproj文件中,我有: <PackageReference Include="Microsoft.AspNetCore.All" Versi
dotnet add package System.IO.FileSystem.DriveInfo
成功无误
在我的.csproj文件中,我有:
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.1.2" />
<PackageReference Include="System.Diagnostics.PerformanceCounter" Version="4.5.0" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="1.0.0" />
<PackageReference Include="System.IO.FileSystem.DriveInfo" Version="4.3.1" />
我得到:
错误CS0234命名空间“System.IO”中不存在类型或命名空间名称“FileSystem”(是否缺少程序集引用?)
我怎样才能解决这个问题?我还可以尝试什么?我只需要:
using System.IO;
然后
我只需要:
using System.IO;
然后
完整的样品
using System.IO;
namespace Sample
{
class Program
{
static void Main(string[] args)
{
DriveInfo dr = new DriveInfo("C");
Console.WriteLine(dr.TotalFreeSpace);
Console.ReadKey();
}
}
}
完整的样品
using System.IO;
namespace Sample
{
class Program
{
static void Main(string[] args)
{
DriveInfo dr = new DriveInfo("C");
Console.WriteLine(dr.TotalFreeSpace);
Console.ReadKey();
}
}
}
包名称不一定映射到名称空间,因此会产生混淆和错误。你到底想做什么?访问GetDrivesTry
System.IO.Directory.GetLogicalDrives()代码>我需要访问TotalFreeSpace的DriveInfo,所以目录没有帮助:(包名称不一定映射到命名空间,因此您会产生混淆和错误。您到底想做什么?访问GetDrivesTrySystem.IO.Directory.GetLogicalDrive();
我需要访问TotalFreeSpace的DriveInfo,所以目录没有帮助:(