Geeks With Blogs
hmloo's World of .NET

When you retrieve the drive info using the DriveInfo class, if you don't use the IsReady property to test whether a drive is ready, it will throw error as "The device is not ready". so you must use IsReady property to determines if the drive is ready to be queried, written to, or read from. The following code example demonstrates querying information for all drives on current system.

using System;
using System.IO;

class Test
    public static void Main()
        DriveInfo[] allDrives = DriveInfo.GetDrives();

        foreach (DriveInfo d in allDrives)
            Console.WriteLine("Drive {0}", d.Name);
            Console.WriteLine("  File type: {0}", d.DriveType);
            if (d.IsReady == true)
                Console.WriteLine("  Volume label: {0}", d.VolumeLabel);
                Console.WriteLine("  File system: {0}", d.DriveFormat);
                    "  Available space to current user:{0, 15} bytes", 

                    "  Total available space:          {0, 15} bytes",

                    "  Total size of drive:            {0, 15} bytes ",
Posted on Sunday, March 18, 2012 6:16 PM C# | Back to top

Comments on this post: The device is not ready

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © hmloo | Powered by: