Exemplo n.º 1
0
 private static DriveInfo[] UnixGetDrives()
 {
     DriveInfo[] array = null;
     try
     {
         using (StreamReader streamReader = DriveInfo.TryOpen("/proc/sys/kernel/ostype"))
         {
             if (streamReader != null)
             {
                 string a = streamReader.ReadLine();
                 if (a == "Linux")
                 {
                     array = DriveInfo.LinuxGetDrives();
                 }
             }
         }
         if (array != null)
         {
             return(array);
         }
     }
     catch (Exception)
     {
     }
     return(new DriveInfo[]
     {
         new DriveInfo(DriveInfo._DriveType.GenericUnix, "/", "unixfs")
     });
 }
Exemplo n.º 2
0
 private static DriveInfo[] LinuxGetDrives()
 {
     DriveInfo[] result;
     using (StreamReader streamReader = DriveInfo.TryOpen("/proc/mounts"))
     {
         ArrayList arrayList = new ArrayList();
         string    text;
         while ((text = streamReader.ReadLine()) != null)
         {
             if (!text.StartsWith("rootfs"))
             {
                 int num = text.IndexOf(' ');
                 if (num != -1)
                 {
                     string text2 = text.Substring(num + 1);
                     num = text2.IndexOf(' ');
                     if (num != -1)
                     {
                         string text3 = text2.Substring(0, num);
                         text2 = text2.Substring(num + 1);
                         num   = text2.IndexOf(' ');
                         if (num != -1)
                         {
                             string fstype = text2.Substring(0, num);
                             arrayList.Add(new DriveInfo(DriveInfo._DriveType.Linux, text3, fstype));
                         }
                     }
                 }
             }
         }
         result = (DriveInfo[])arrayList.ToArray(typeof(DriveInfo));
     }
     return(result);
 }