遍历所有驱动器,包括隐藏 [英] Loop through all drives including hidden

查看:89
本文介绍了遍历所有驱动器,包括隐藏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法循环所有计算机驱动器,如usb或逻辑一次,包括隐藏的那些?我搜索但是没有找到任何有关隐藏驱动器的信息。是否有任何参考?

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?

推荐答案

嗨JimmyJimm,

Hi JimmyJimm,

感谢您在此发帖。

对于你的问题,你如何获得驱动程序?你能否提供代码。

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();

最诚挚的问候,

Wendy


这篇关于遍历所有驱动器,包括隐藏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆