DriveInfo在当前上下文中不存在?

Art*_*ani 2 c# linq driver

为什么我在下面的C#LINQ代码中收到以下错误

DriveInfo does not exist in current context?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var drives = DriveInfo.GetDrives()
             .Where(drive => drive.IsReady && drive.DriveType == DriveType.Removable);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

提前谢谢了!

Jon*_*eet 5

你需要一个using指令:

using System.IO;
Run Code Online (Sandbox Code Playgroud)

...导入System.IO.DriveInfo.