隱藏/顯示Form標題欄:
隱藏Form標題欄:
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
顯示Form標題欄:
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable;
//除了None之外很多選項都可以
隱藏/顯示Tabpage:
以下為示意圖,tabControl1 為TabControl的Name
]
隱藏Tabpage:
this.tabPage2.Parent = null;
//將Parent設為null 即可隱藏
顯示Tabpage:
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable;
//除了None之外很多選項都可以
private void showDisk()
{
DriveInfo[] allDrives = DriveInfo.GetDrives();
foreach (DriveInfo driveInfo in allDrives)
{
if (driveInfo.IsReady)
{
long totalSizeInBytes = driveInfo.TotalSize;
long availableSpaceInBytes = driveInfo.AvailableFreeSpace;
long totalFreeSpaceInBytes = driveInfo.TotalFreeSpace;
// 將位元組轉換為其他單位,例如GB
double totalSizeInGB = ConvertBytesToGB(totalSizeInBytes);
double availableSpaceInGB = ConvertBytesToGB(availableSpaceInBytes);
double totalFreeSpaceInGB = ConvertBytesToGB(totalFreeSpaceInBytes);
TbConsole.AppendText($"磁碟({driveInfo.Name}):" + Environment.NewLine);
TbConsole.AppendText($"總大小: {totalSizeInGB} GB" + Environment.NewLine);
TbConsole.AppendText($"可用空間: {availableSpaceInGB} GB" + Environment.NewLine);
TbConsole.AppendText($"總剩餘空間: {totalFreeSpaceInGB} GB" + Environment.NewLine);
Console.WriteLine();
}
}
}
double ConvertBytesToGB(long bytes)
{
return bytes / (1024.0 * 1024.0 * 1024.0);
}
private void btnRun_Click(object sender, EventArgs e)
{
showDisk();
}
期望挑戰30天持續更新成功 ~ DAY28