C # driveinfo: the troubleshooting method for reading drive errors is very naive!

Source: Internet
Author: User

Test code:

Using system;
Using system. Collections. Generic;
Using system. text;
Using system. IO;

Namespace driveinfohelper
{
Class Program
{
Static void main (string [] ARGs)
{
Driveinfo [] drives = driveinfo. getdrives ();
Console. writeline ("drive name/T type/T format/T total space/T available space ");
Foreach (driveinfo di in drives)
{
Console. writeline (string. format ("{0}/T {1}/t {2}/t {3}/t {4}", Di. name, Di. drivetype, Di. driveformat, Di. totalsize, Di. totalfreespace ));
}
}
}
}
Error message:

Drive name Type format total space available
C:/fixed NTFS 132409556992 103559319552
D:/fixed NTFS 20970467328 875720704

Unprocessed exception: system. Io. ioexception: the device is not ready.

In system. Io. _ error. winioerror (int32 errorcode, string maybefullpath)
In system. Io. _ error. winiodriveerror (string drivename, int32 errorcode)
In system. Io. driveinfo. get_driveformat ()
In driveinfohelper. program. Main (string [] ARGs) Location D:/exercises/driveinfoel
PER/driveinfohelper/program. CS: row number 16
Press any key to continue...
When the optical drive is attached to a CD, the following message is displayed:

Drive name Type format total space available
C:/fixed NTFS 132409556992 103559266304
D:/fixed NTFS 20970467328 875720704
E:/CDROM, CDFs 719345664, 0
Press any key to continue...
Note: It turns out that the optical drive is not equipped with a CD! Haha

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.