Drive.cs
Description du code
Drive.cs est un fichier du projet BrolExplorer.Ce fichier est situé dans /var/www/bin/sniplets/bibliobrol/brolexplorer/.
Projet BrolExplorer :
Explorateur de media en CSharp.
Code source ou contenu du fichier
Code c# (Drive.cs) (173 lignes)
using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using be.gaudry.model.enums; using be.gaudry.model; using System.IO; using be.gaudry.model.drawing; namespace be.gaudry.explorer.model { public class Drive { [DllImport("kernel32.dll")] public static extern long GetDriveType(string driveLetter); /*[DllImport("kernel32.dll")] public static extern long GetVolumeInformation( string strPathName, StringBuilder strVolumeNameBuffer, long lngVolumeNameSize, long lngVolumeSerialNumber, long lngMaximumComponentLength, long lngFileSystemFlags, StringBuilder strFileSystemNameBuffer, long lngFileSystemNameSize );*/ /// <summary> /// Deprecated : use "internal static SHELL32_ICON getDriveIcon(System.IO.DriveInfo di)" instead /// </summary> /// <param name="drive"></param> /// <returns></returns> public static SHELL32_ICON getDriveType(string drive) { long driveType = GetDriveType(drive); switch (driveType) { case 8976214553213796355: return SHELL32_ICON.drive_HD; case 8976214553213796357: return SHELL32_ICON.drive_cd; //case 8976214553213796357: return SYSTEM_ICON.drive_removable; case 8976214553213796354: return SHELL32_ICON.drive_floppy; //case 8976214553213796357: return SYSTEM_ICON.drive_remoteDisk; //case 8976214553213796357: return SYSTEM_ICON.drivr_ramDisk; } //if ((driveType & 3) == 3) return SYSTEM_ICON.drive_HD; //if ((driveType & 5) == 5) return SYSTEM_ICON.drive_cd; if ((driveType & 2) == 2) return SHELL32_ICON.drive_removable; if ((driveType & 4) == 4) return SHELL32_ICON.drive_remoteDisk; if ((driveType & 6) == 6) return SHELL32_ICON.drive_ramDisk; return SHELL32_ICON.drive_HD; } internal static SHELL32_ICON getDriveIcon(System.IO.DriveInfo di) { switch (di.DriveType) { case System.IO.DriveType.CDRom: return SHELL32_ICON.drive_cd; case System.IO.DriveType.Fixed: return SHELL32_ICON.drive_HD; case System.IO.DriveType.Network: return SHELL32_ICON.drive_remoteDisk; case System.IO.DriveType.Removable: return SHELL32_ICON.drive_removable; case System.IO.DriveType.NoRootDirectory: return SHELL32_ICON.folderClosed; case System.IO.DriveType.Ram: return SHELL32_ICON.drive_ramDisk; case System.IO.DriveType.Unknown: return SHELL32_ICON.drive_HD; } return SHELL32_ICON.drive_HD; } public class DriveInfoHelper { private string text, toolTipText; private SHELL32_ICON iconType; private DriveInfo driveInfo; public DriveInfoHelper(System.IO.DriveInfo drive) { driveInfo = drive; try { if (drive.IsReady) { toolTipText = string.Format("{0} pour {1} ({2}% d'espace libre)", Units.getLengthString(drive.TotalSize), drive.VolumeLabel.Equals(string.Empty) ? drive.Name : drive.VolumeLabel, Convert.ToInt16(((Double)drive.AvailableFreeSpace / drive.TotalSize) * 100) ); text = string.Format( "{0} ({1})", drive.VolumeLabel.Equals(string.Empty) ? drive.Name : drive.VolumeLabel, drive.Name.Remove(1) ); } else { toolTipText = string.Format("{0} non disponible.", drive.Name ); text = drive.Name; } switch (drive.DriveType) { case System.IO.DriveType.CDRom: if (drive.IsReady) { iconType = SHELL32_ICON.disc; } else { iconType = SHELL32_ICON.drive_cd; } break; case System.IO.DriveType.Fixed: iconType = SHELL32_ICON.drive_HD; break; case System.IO.DriveType.Network: iconType = SHELL32_ICON.drive_remoteDisk; break; case System.IO.DriveType.Removable: iconType = SHELL32_ICON.drive_removable; break; case System.IO.DriveType.NoRootDirectory: iconType = SHELL32_ICON.folderClosed; break; case System.IO.DriveType.Ram: iconType = SHELL32_ICON.drive_ramDisk; break; case System.IO.DriveType.Unknown: iconType = SHELL32_ICON.drive_HD; break; default: iconType = SHELL32_ICON.drive_HD; break; } } catch (IOException e) { toolTipText = e.Message; } } public string Text { get { return text; } } public string ToolTipText { get { return toolTipText; } } public SHELL32_ICON IconType { get { return iconType; } } public System.Drawing.Image Icon { get { return IconExtractor.getShell32Bitmap(iconType); } } public DriveInfo DriveInfo { get { return driveInfo; } } } } }
Structure et Fichiers du projet
Afficher/masquer...Icône | Nom | Taille | Modification |
Pas de sous-répertoires. | |||
Icône | Nom | Taille | Modification |
| _ | Répertoire parent | 0 octets | 1734903567 22/12/2024 22:39:27 |
Utilisation de l'explorateur de code
- Navigation :
- Un clic sur une icône de répertoire ouvre ce répertoire pour en afficher les fichiers.
- Lorsque le répertoire en cours ne contient pas de sous-répertoires il est possible de remonter vers le répertoire parent.
- La structure de répertoires en treetable (tableau en forme d'arborescence) n'est plus possibledans cette version.
- Un clic sur une icône de fichier ouvre ce fichier pour en afficher le code avec la coloration syntaxique adaptée en fonction du langage principal utilisé dans le fichier.
- Affichage :
- Il est possible de trier les répertoires ou les fichiers selon certains critères (nom, taille, date).
- Actions :
- Les actions possible sur les fichiers dépendent de vos droits d'utilisateur sur le site. Veuillez activer le mode utilisateur pour activer les actions.
English translation
You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.
Thank you in advance.
Document created the 30/10/2009, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/cs-brolexplorer-source-rf-model//Drive.cs.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.