Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
I am doing one disk management application. I can take out the discs that have been created. The main problem is to see what has not been created. And to make them unit and shape. I do not want to use Windows's disk management application. What should I do for this? What I do is almost identical to the Windows Disk Management application.

What I have tried:

I have tried with WMI and Drive Info but I can not see disks that have not been created yet.

Here is one of the codes I tried:
DataTable dt = new DataTable();
           dt.Clear();
           dt.Columns.Add("Name");
           dt.Columns.Add("Volume Label");
           dt.Columns.Add("Type");
           dt.Columns.Add("Size");
           dt.Columns.Add("Format");
           dt.Columns.Add("Status");
           dt.Columns.Add("Free Space");


           dt.Columns.Add("Byte");


           DriveInfo[] driverslist = DriveInfo.GetDrives();
           foreach (DriveInfo d in driverslist)
           {


               if (d.IsReady == true)
               {

                   size = FormatBytes(Convert.ToInt64(d.TotalSize));
                   totalfreesize = FormatBytes(Convert.ToInt64(d.TotalFreeSpace));

                   dt.Rows.Add(d.Name, d.VolumeLabel, d.DriveType, size, d.DriveFormat, d.IsReady, totalfreesize, d.TotalSize);
               }
           }
           dataGrid.ItemsSource = dt.DefaultView;
I pull the harddisks in here and transfer them to the table.
Posted
Updated 25-Jul-18 4:57am
v2
Comments
Richard MacCutchan 25-Jul-18 13:31pm    
"What I do is almost identical to the Windows Disk Management application."
Looking at your code I find that hard to believe. And you should understand that DriveInfo.GetDrives() only provides information about existing logical drives. So any space allocated to other partition types will not be provided.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900