2011-02-16 28 views
3

如何在c#中的硬盤驅動器中的所有分區只是不寫目錄路徑。因爲有些人把硬盤分成3份,4份也許是5份,我希望我的程序能夠完全搜索。我如何才能達到在硬盤驅動器中的所有分區在c#

這樣

List<string> dirs = FileHelper.GetFilesRecursive("c:\\.........."); 

我不想只是想CI d,E,F .......等

+0

您的驅動器C是不是一個物理驅動器,它是一個物理硬盤上的分區(也許只有一個或一個出來的幾個)。 – sstn 2011-02-16 11:19:32

回答

4

你可以使用:

// Store the list of drives into an array of string 
string[] DriveList = Environment.GetLogicalDrives(); 
// Loop through the array 
for (int i = 0; i < DriveList.Length; i++) 
{ 
    // Show each drive 
    MessageBox.Show(DriveList[i]); 
} 
相關問題