Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

SOLVED: Repartition a USB device using DiskPart

Luca Carlon:

I would like to repartition a USB drive using Diskpart from a C# application. This seems reasonably simple: I collect data about plugged disks using the Win32_DiskDrive class and then use DiskPart to run a script that will change the partitions. Critical point seems to be that of mapping the entry I select from Win32_DiskDrive to a Disk number in DiskPart. For instance, this is the output of DiskPart:


DISKPART> list disk

Disk ### Status Size Free Dyn Gpt
-------- ------------- ------- ------- --- ---
* Disk 0 Online 100 GB 0 B
Disk 1 Online 14 GB 0 B

I need to select the disk by its number. But where do I get that number from data retrieved using Win32_DiskDrive? I guess the answer is using the "DeviceID" field, which returns this "\\.\PHYSICALDRIVE0". The index at the end seems to be the one I need to match the entry from Win32_DiskDrive with the related entry from DiskPart. Is this correct? Critical question is: is there any place in the official docs where this is stated without doubts? I will then format the device so I cannot do anything wrong here. Thanks.



Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
This Question have been answered
HERE


This post first appeared on Stack Solved, please read the originial post: here

Share the post

SOLVED: Repartition a USB device using DiskPart

×

Subscribe to Stack Solved

Get updates delivered right to your inbox!

Thank you for your subscription

×