【发布时间】:2012-08-14 13:29:59
【问题描述】:
使用下面的代码,命令提示符在出现后几乎立即消失。此代码不应该显示所有正在使用的可移动驱动器吗?
using System.Linq;
using System.IO;
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
var drives = DriveInfo.GetDrives()
.Where(drive => drive.IsReady && drive.DriveType == DriveType.Removable);
Console.WriteLine("Removable drives being used:", drives);
}
}
}
非常感谢!
【问题讨论】:
-
在
Main末尾添加Console.Read();。 -
调试的时候是按F5还是按Crtl + F5?
-
Ctrl+F5在没有调试器的情况下启动您的应用程序。它在此模式下的行为有所不同;命令窗口保持打开状态并显示“按任意键继续”。
标签: c# linq command-prompt