Nagendra Panyam

Nagendra Panyam

  • NA
  • 190
  • 17.5k

working with drives

Feb 14 2019 9:04 PM
foreach (DiskinfoDetails item in diskList1)
{
if (item.Status.Equals("Unencrypted") || item.Status.Equals("Encryption paused") || item.Status.Equals("Encryption in-progress"))
{
continue;
}
if (result == 3)
{
SystemStateInfo systemStateInfo = SystemDataLib.GetSystemState();
systemStateInfo.SystemState = ENUMSYSTEMSTATE.ENCRYPTION_COMPLETED;
SystemDataLib.SaveSystemState(systemStateInfo);
SystemDataLib.UpdateDiskStatus("Encryption Completed");
//diskList2.Add(item);
// Refresh Grid
//DriveInformation.Clear();
var data = GetSystemInfoHelper.GetPartitons();
foreach (var diskInformation in data)
{
if (bootDrive != null && item.DriveLetter == bootDrive.Replace(":", ""))
{
item.DriveSize = diskInformation.DriveSize;
item.DiskLabel = diskInformation.DiskLabel;
item.DevicePath = diskInformation.DevicePath;
item.Status = diskInformation.Status;
item.IsWindowsDrive = diskInformation.IsWindowsDrive;
break;
}
}
}
if (result == 4)
{
SystemStateInfo systemStateInfo = SystemDataLib.GetSystemState();
systemStateInfo.SystemState = ENUMSYSTEMSTATE.DECRYPTION_INPROGRESS;
SystemDataLib.SaveSystemState(systemStateInfo);
SystemDataLib.UpdateDiskStatus("Decryption In-progress");
//diskList2.Add(item);
// Refresh Grid
//DriveInformation.Clear();
var data = GetSystemInfoHelper.GetPartitons();
foreach (var diskInformation in data)
{
if (bootDrive != null && item.DriveLetter == bootDrive.Replace(":", ""))
{
item.DriveSize = diskInformation.DriveSize;
item.DiskLabel = diskInformation.DiskLabel;
item.DevicePath = diskInformation.DevicePath;
item.Status = diskInformation.Status;
item.IsWindowsDrive = diskInformation.IsWindowsDrive;
break;
}
}
}
if (result == 1)
{
SystemStateInfo systemStateInfo = SystemDataLib.GetSystemState();
systemStateInfo.SystemState = ENUMSYSTEMSTATE.DECRYPTION_COMPLETED;
SystemDataLib.SaveSystemState(systemStateInfo);
SystemDataLib.UpdateDiskStatus("Unencrypted");
BootDriveSystemSateInfo bootDriveSystemSate = SystemDataLib.GetBootDriveSystemSate();
bootDriveSystemSate.SystemState = ENUMSYSTEMSTATE.DECRYPTION_COMPLETED;
SystemDataLib.SaveBootDriveSystemState(bootDriveSystemSate);
var data = GetSystemInfoHelper.GetPartitons();
foreach (var diskInformation in data)
{
if (bootDrive != null && item.DriveLetter == bootDrive.Replace(":", ""))
{
item.DriveSize = diskInformation.DriveSize;
item.DiskLabel = diskInformation.DiskLabel;
item.DevicePath = diskInformation.DevicePath;
item.Status = diskInformation.Status;
item.IsWindowsDrive = diskInformation.IsWindowsDrive;
break;
}
}
}
diskList2.Add(item);
}
 
 
 
can i modify above logic to any simple,bcause it tooks more time to get system drives 

Answers (6)