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

时间:2012-08-14 13:11:25

标签: 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);
        }
    }
}

非常感谢提前!

1 个答案:

答案 0 :(得分:5)

您需要using指令:

using System.IO;

...导入System.IO.DriveInfo