We should all know how to save a text file like so:
richTextBox1.SaveFile(@"C:\hello.txt", RichTextBoxStreamType.PlainText);
But I want to save it to an external drive. So I would try:
richTextBox1.SaveFile(@"F:\hello.txt", RichTextBoxStreamType.PlainText);
BUT, F: can change to G: or E:, etc... F: usually has a name such as 'SD Card', though.
So how do I save to the Removable Disk 'SD Card' based on it's name?
JurePosted Nov 29, 2010, 12:42 PM
List
foreach (DriveInfo d in drives)
{
if (d.DriveType == DriveType.Removable)
removables.Add(d.Name);
}
foreach (string r in removables)
{
Console.WriteLine(r); // outputs all removable drives, such as "F:\"
}
Use DriveInfo.VolumeLabel property if you need to get the label (e.g. "SD Card").