using System.IO;

--------------------------------------------------------------------------------------

private void GetDeveiceSize()

        {

            //Console.WriteLine("folder:"+_FOLDER);

            

            string device = _FOLDER.Substring(0, 3);

            Console.WriteLine("device:"+device);

            //取得所有磁碟機的DriveInfo類別

            DriveInfo[] ListDrivesInfo = DriveInfo.GetDrives();

            try

            {

                foreach (DriveInfo vListDrivesInfo in ListDrivesInfo)

                {

                    //使用IsReady屬性判斷裝置是否就緒

                    if (vListDrivesInfo.IsReady)

                    {

                        Console.WriteLine("磁碟代號:" + vListDrivesInfo.Name);

                        Console.WriteLine("磁碟標籤:" + vListDrivesInfo.VolumeLabel);

                        Console.WriteLine("磁碟類型:" + vListDrivesInfo.DriveType.ToString());

                        Console.WriteLine("磁碟格式:" + vListDrivesInfo.DriveFormat);

                        Console.WriteLine("磁碟大小:" + vListDrivesInfo.TotalSize.ToString());

                        Console.WriteLine("剩餘空間:" + vListDrivesInfo.AvailableFreeSpace.ToString());

                        Console.WriteLine("總剩餘空間(含磁碟配碟):" + vListDrivesInfo.TotalFreeSpace.ToString());

                        Console.WriteLine("=================================");                      

                    }

                }

 

            }

            catch (Exception ex)

            {

                Console.WriteLine("ex:" + ex.Message);

              

            }

        }

arrow
arrow
    全站熱搜

    狼翔月影 發表在 痞客邦 留言(0) 人氣()