To get the system drives in C# and VB.NET you can use the following snippet.
Sample C#
public static DriveInfo[] GetDrives(bool runningDrivesOnly) { return runningDrivesOnly ? Enumerable.Cast<DriveInfo>(DriveInfo.GetDrives()).Where(x => x.IsReady).ToArray() : DriveInfo.GetDrives(); }
Sample VB.NET
Public Shared Function GetDrives(runningDrivesOnly As Boolean) As DriveInfo() Return If(runningDrivesOnly, Enumerable.Cast(Of DriveInfo)(DriveInfo.GetDrives()).Where(Function(x) x.IsReady).ToArray(), DriveInfo.GetDrives()) End Function
RT @CodeSnippetsNET: How to get the system drives in .NET http://t.co/vAYOp9Xpr4 #csharp #vb #dotnet #programming #coding #dev