C#控制台基础 在查询硬盘的空间是出现system.IO.IOexception
2016-08-07 19:55
387 查看
慈心积善融学习,技术愿为有情学。善心速造多好事,前人栽树后乘凉。我今于此写经验,愿见文者得启发。
我的代码是:
改正代码,
刚才的错误出现在这里,我的CDROM是E盘,但是这个CDROM没有空间什么的,所以程序就尴尬了。
指导链接:http://bbs.csdn.net/topics/280049114
http://bbs.csdn.net/topics/350036201 http://zhidao.baidu.com/link?url=36C9oYdK9mcfjElhJ6wJD_XQJtxmjQFvTgbfOPHi6dUkJpRdWa23UMrDg2AdNFuUhF8oyAbsPS9YytGOXOCaAq
感恩曾经帮助过 心少朴 的人。
C#优秀,值得学习。Console,ASP.NET,Winform,WPF,设计模式等都可以关注一下,眼界要开阔。
Visual Studio IDE很好用,推荐!
注:此文是自学笔记所生,质量中等,故要三思而后行。新手到此,不可照搬,应先研究其理象数,待能变通之时,自然跳出深坑。
我的代码是:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO;//这个using 不可缺少 namespace ConsoleApplication1 { class Program { static void Main(string[] args) { var allDrives = DriveInfo.GetDrives(); foreach(var aDrive in allDrives) { Console.WriteLine(aDrive.TotalFreeSpace); } Console.ReadKey(); } } }
改正代码,
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO;//这个using 不可缺少 namespace ConsoleApplication1 { class Program { static void Main(string[] args) { var allDrives = DriveInfo.GetDrives(); foreach(var aDrive in allDrives) { if(aDrive.IsReady==true)//驱动器准备好了吗? Console.WriteLine(aDrive.TotalFreeSpace); } Console.ReadKey(); } } }
刚才的错误出现在这里,我的CDROM是E盘,但是这个CDROM没有空间什么的,所以程序就尴尬了。
指导链接:http://bbs.csdn.net/topics/280049114
http://bbs.csdn.net/topics/350036201 http://zhidao.baidu.com/link?url=36C9oYdK9mcfjElhJ6wJD_XQJtxmjQFvTgbfOPHi6dUkJpRdWa23UMrDg2AdNFuUhF8oyAbsPS9YytGOXOCaAq
感恩曾经帮助过 心少朴 的人。
C#优秀,值得学习。Console,ASP.NET,Winform,WPF,设计模式等都可以关注一下,眼界要开阔。
Visual Studio IDE很好用,推荐!
注:此文是自学笔记所生,质量中等,故要三思而后行。新手到此,不可照搬,应先研究其理象数,待能变通之时,自然跳出深坑。
相关文章推荐
- C#串口通讯出现在 System.IO.IOException 中第一次偶然出现的“System.dll”类型的异常的解决办法
- C#控制台基础 得到一个字符串中每个字母出现的次数
- C#_IO操作_查询指定文件夹下的每个子文件夹占空间的大小
- C#控制台基础 分析system.console.writeline("hello");的语句成分
- web Services “/”应用程序中的服务器错误。异常详细信息: System.IO.IOException: 磁盘空间不足。
- C#文件处理-System.IO 命名空间常用的类
- C#控制台基础 使用split分离字符串出现了很多的空,怎么除去空
- C#学习常用的命名空间---System.Data.Linq(语言集成查询)
- C#学习常用命名空间【3000】---System.IO
- c# 命名空间之System.IO(继承关系)
- C#控制台基础 assembly与fullname获取一个dll中所有的命名空间
- C#控制台基础 获取电脑上的所有逻辑驱动器的名称,可用空间,总空间
- C# System.IO命名空间
- https使用HttpWebRequest出现错误:System.IO.IOException: Received an unexpected EOF or 0 bytes from the transport stream.的解决方法
- 详情学习C#中System.IO.File类和System.IO.FileInfo类的用法2
- C# post数据时 出现如下错误: System.Net.WebException: 远程服务器返回错误: (417) Expectation Failed 的解决办法
- 详情学习C#中System.IO.File类和System.IO.FileInfo类的用法3
- 用C#的两种取得硬盘剩余空间方法
- System.IO.IOException: 无法从传输连接中读取数据: net_io_connectionclosed
- c# winform 控制台基础程序,冒泡排序法