I need to develope an application (Windows Forms) which facilitate the user the action of change a disk letter. I know how to do it from cmd:
- diskpart
- List volume
- Select volume X
- Assign letter = K
The interface for my app is supposed to be something like this:
I know how to execute these commands from c#, but I would like to show the result of "List volume" command in my list box in order the user can select the volume they wanted to change the letter and press the button "CHANGE LETTER".
My question is how to do the first task, I mean, show the result of List volume in the list box.
Here is my code since now:
Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = @"C:\Windows\System32\diskpart.exe";
p.StartInfo.RedirectStandardInput = true;
p.Start();
p.StandardInput.WriteLine("list volume");
string output = p.StandardOutput.ReadToEnd();
I can't see the value of output when I run the program. Thank you for your help!