none
Loop through all drives including hidden RRS feed

  • Question

  • Is there any way to loop though all computer drives like usb or logical once including those which are hidden? I searched but haven;t found anything about hidden drives. Is there any reference for that?
    Thursday, August 16, 2018 10:33 AM

All replies

  • Hi JimmyJimm,

    Thank you for posting here.

    For your question, how do you get the drivers? Could you provide the code.

    Based on my side, the code below works well for me.

     DriveInfo[] allDrives = DriveInfo.GetDrives();
    
                foreach (DriveInfo d in allDrives)
                {                
                    Console.WriteLine("Drive {0}", d.Name);
                    Console.WriteLine("  Drive type: {0}", d.DriveType);
                    if (d.IsReady == true)
                    {
                        Console.WriteLine("  Volume label: {0}", d.VolumeLabel);
                        Console.WriteLine("  File system: {0}", d.DriveFormat);
                        Console.WriteLine(
                            "  Available space to current user:{0, 15} bytes",
                            d.AvailableFreeSpace);
    
                        Console.WriteLine(
                            "  Total available space:          {0, 15} bytes",
                            d.TotalFreeSpace);
    
                        Console.WriteLine(
                            "  Total size of drive:            {0, 15} bytes ",
                            d.TotalSize);
                    }
                }
                Console.ReadKey();

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Proposed as answer by Stanly Fan Wednesday, August 22, 2018 2:17 AM
    Monday, August 20, 2018 5:12 AM
    Moderator
  • Does this show also hidden drives?
    Wednesday, August 22, 2018 6:36 AM