I want to get the list of removable disk in c#. I want to skip the local drives. Because i want the user to save the file only in removable disk.
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Generic Generics in Managed C++
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
How about:
You can also use WMI to get the list of removable drives.
Edited based on comment:
After you get the list of drives get there GUID's and add them to SaveFileDialogInstance.CustomPlaces collection.
The code below need some tweaking...
This article looks to do the trick:
http://zayko.net/post/How-to-get-list-of-removable-drives-installed-on-a-computer-(C).aspx
You will need to reference
System.IO
for this method.Or for the LINQ fans:
Added
As for the Saving part, as far as I know I don't think you can restrict where the user is allowed to save to using a SaveFileDialog, but you could complete a check after you have shown the SaveFileDialog.
OR
The best option would be to create your own Save Dialog, which contains a tree view, only showing the removable drives and their contents for the user to save to! I would recommend this option.
Hope this helps