C# 错误:设备未就绪
错误地点:long sizeused = drive.TotalSize - drive.TotalFreeSpace;
long sizeUsed = sizeused / 1024 / 1024 / 1024 / 1024;
long totaSize = drive.TotalSize / 1024 / 1024 / 1024;
long freeSize = drive.TotalFreeSpace / 1024 / 1024 / 1024;
float use = (float)sizeUsed;
float all = (float)totaSize;
int w = Convert.ToInt32((use / all) * (DiskSize.Width - 2));
DiskUsed.Width = w;
labDiskName.Text = drive.VolumeLabel + "(" + drive.Name + ")";
labDiskInfo.Text = ((float)drive.TotalFreeSpace / 1024 / 1024 / 1024).ToString("0.00") + " GB 可用,共 " + ((float)drive.TotalSize / 1024 / 1024 / 1024).ToString("0.00") + " GB ";
------解决方案--------------------
你访问了软盘光盘之类的,对他们获取容量就会出现这个错误。
最好先判断下Driver.Type
------解决方案--------------------
刚刚遇到这个问题了,,,
访问的磁盘在本机不存在