using namespace System::IO;

	try
	{
		array<DriveInfo^> ^allDrives = DriveInfo::GetDrives();

		for each (DriveInfo ^drive in allDrives)
		{
			sTemp += "Drive Name: " + drive->Name;
			sTemp += ", Type " + Convert::ToString(drive->DriveType);
			if ((drive->DriveType == DriveType::Fixed) && (drive->IsReady))
			{
				sTemp += ", Volume Label: " + drive->VolumeLabel;
				sTemp += ", File System: " + drive->DriveFormat;

				if (drive->TotalSize >= 1073741824)
					sTemp += ", Total size: " + Convert::ToInt64(drive->TotalSize / 1073741824) + " GB";
				else if (drive->TotalSize >= 1048576)
					sTemp += ", Total size: " + Convert::ToInt64(drive->TotalSize / 1048576) + " MB";
				else
					sTemp += ", Total size: " + drive->TotalSize / 1048576 + " bytes";

				if (drive->TotalFreeSpace >= 1073741824)
					sTemp += ", Total available space: " + Convert::ToInt64(drive->TotalFreeSpace / 1073741824) + " GB";
				else if (drive->TotalFreeSpace >= 1048576)
					sTemp += ", Total available space: " + Convert::ToInt64(drive->TotalFreeSpace / 1048576) + " MB";
				else
					sTemp += ", Total available space: " + drive->TotalFreeSpace + " bytes";

				if (drive->AvailableFreeSpace >= 1073741824)
					sTemp += ", Available space to current user: " + Convert::ToInt64(drive->AvailableFreeSpace / 1073741824) + " GB";
				else if (drive->AvailableFreeSpace >= 1048576)
					sTemp += ", Available space to current user: " + Convert::ToInt64(drive->AvailableFreeSpace / 1048576) + " MB";
				else
					sTemp += ", Available space to current user: " + drive->AvailableFreeSpace + " bytes";
			}
			sTemp += "\r\n";
		}
	}
	catch (Exception ^)
	{
	}
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published.