I want to show a open dialog for the user, where the user can select only the files from the removable disks in the system. I am using the below code. But i need to get the Guid of removable disk to open the dialog.
Tell me how…
System.Windows.Forms.OpenFileDialog dls = new System.Windows.Forms.OpenFileDialog();
dls.CustomPlaces.Clear();
foreach (DriveInfo Drive in ListDrives)
{
if (Drive.DriveType == DriveType.Removable)
{
dls.CustomPlaces.Add(-----Guid of Drive------);
}
dls.ShowDialog();
}
I don’t have an answer how to get the Guids for the removable drives, however setting the
CustomPlacescollection will not restrict your users from selecting anything but the folders in the collection, they will simply show up as shortcuts on the left of the open file dialog, and then only if you have theAutoUpgradeEnabledproptery set totrueand your users are running Windows Vista or higher.See: http://msdn.microsoft.com/en-us/library/bb397814.aspx
Although, to finish off where you started, use the
DriveInfo.Nameto create a new entry in your custom places: