1
Fork 0
This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
saviour-backup-system/Snippets/Read XML from USB.cs

37 lines
1 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using System.IO;
namespace Read_USB_XML
{
class Program
{
static void Main(string[] args)
{
DriveInfo[] drives = DriveInfo.GetDrives();
for (int i = 0; i < drives.Count(); i++)
{
string driveName;
string driveLetter;
try //if the volume label is invalid (CD Drive in laptop), then the program crashes
{
driveName = drives[i].VolumeLabel;
driveLetter = drives[i].Name;
} catch {
continue;
}
if (driveName == "")
{
driveName = "Unnamed Volume";
}
Console.WriteLine("Drive " + i + ": " + driveLetter + ". Drive Label: " + driveName);
}
Console.ReadKey();
}
}
}