내 코드에서 DriveInfo.GetDrives() 메서드를 사용하여 지정된 컴퓨터에서 사용 가능한 모든 준비된 이동식 드라이브로 콤보 상자를 채 웁니다. 세 대의 테스트 컴퓨터에서 잘 작동하지만 단일 컴퓨터에서 사용자가 콤보 상자 (및 생성자의 GetDrives)가있는 창을 여는 단추를 클릭하면 창이 열리기 전에 몇 초가 걸립니다.선택 컴퓨터에서 DriveInfo.GetDrives() 속도가 느림
컴퓨터에서 Windows 7을 실행 중이고 주목할 점은 RAID 설정이 있다는 것입니다.
일단 열면 반응하기 때문에 어떤 이유로 열릴 때 멈 춥니 다. MSDN 설명서에서 도움이되는 것을 찾을 수 없었으며 온라인에서도 비슷한 사례를 발견하지 못했습니다. 유사한 문제 나 제안 사항이있는 경우 알려 주시기 바랍니다.
내 프로젝트에서 DriveInfo를 사용하는 창을 추출하고 테스트 응용 프로그램을 만들었습니다.
이public partial class MainWindow : Window
{
//Instance variables used in class and refrenced in 'get' methods
int count;
string[] driveNames;
public MainWindow() //Constructor
{
InitializeComponent();
getInfo(); //Populate instance vars
}
public string[] getRemovableDrives() //Returns array of drive letters for removable drives in computer
{
return driveNames;
}
public int getRemovableDrivesCount() //Returns number of removable drives in computer
{
return count;
}
private void getInfo() //Run once to get information about removable drives on computer and store into instance vars
{
count = 0;
List<string> drivesTemp = new List<string>();
foreach (DriveInfo d in DriveInfo.GetDrives())
{
if (d.IsReady == true && d.DriveType == DriveType.Removable && d.DriveFormat == "FAT32")
{
drives.Items.Add(d.VolumeLabel + " (" + d.Name + ")");
drivesTemp.Add(d.Name);
count++;
}
}
driveNames = new string[count];
for (int i = 0; i < count; i++)
{
driveNames[i] = drivesTemp[i];
}
}
private void Window_Loaded(object sender, RoutedEventArgs e) //Selects first available drive in drop down box
{
drives.SelectedIndex = drives.Items.Count - 1;
}
private void format_Click(object sender, RoutedEventArgs e) //Attempts to format drive
{
string drive = driveNames[drives.SelectedIndex];
try
{
Directory.CreateDirectory(drive + "LOOKOUT.SD");
Directory.CreateDirectory(drive + "LOOKOUT.SD\\CONFIG");
Directory.CreateDirectory(drive + "LOOKOUT.SD\\HISTORY");
Directory.CreateDirectory(drive + "LOOKOUT.SD\\TEST");
Directory.CreateDirectory(drive + "LOOKOUT.SD\\UPDATES");
Directory.CreateDirectory(drive + "LOOKOUT.SD\\VPROMPTS");
MessageBox.Show("Format complete, your removable device is now ready to use.", "Format Successful", MessageBoxButton.OK, MessageBoxImage.Information);
}
catch
{
MessageBox.Show("Your removable device has failed to format correctly.", "Format Failure", MessageBoxButton.OK, MessageBoxImage.Exclamation);
}
Close();
}
private void cancel_Click(object sender, RoutedEventArgs e) //Closes window without formatting
{
Close();
}
}
반복적으로 느려지 는가, 아니면 처음인가? 아마 드라이브가 비활성 상태 였고 지연 중에 회전하고있는 것 같아요. –
반복적으로 천천히, 나는 위의 코드를 게시 할 것이다 –