/// <summary>
        /// Retrieves the drive names of all logical drives on a computer.
        /// </summary>
        /// <returns>An array of type <see cref="DriveInfoBase"/> that represents the logical drives on a computer.</returns>
        public DriveInfoBase[] GetDrives()
        {
            var driveInfos = DriveInfo.GetDrives();
            var driveInfoWrappers = new DriveInfoBase[driveInfos.Length];
            for (int index = 0; index < driveInfos.Length; index++)
            {
                var driveInfo = driveInfos[index];
                driveInfoWrappers[index] = new DriveInfoWrapper(driveInfo);
            }

            return driveInfoWrappers;
        }
        /// <summary>
        /// Retrieves the drive names of all logical drives on a computer.
        /// </summary>
        /// <returns>An array of type <see cref="DriveInfoBase"/> that represents the logical drives on a computer.</returns>
        public DriveInfoBase[] GetDrives()
        {
            DriveInfo[]     driveInfos        = DriveInfo.GetDrives();
            DriveInfoBase[] driveInfoWrappers = new DriveInfoBase[driveInfos.Length];
            for (int index = 0; index < driveInfos.Length; index++)
            {
                DriveInfo driveInfo = driveInfos[index];
                driveInfoWrappers[index] = new DriveInfoWrapper(driveInfo);
            }

            return(driveInfoWrappers);
        }
Ejemplo n.º 3
0
    public static List <DriveInfoWrapper> ListDrives()
    {
        List <DriveInfoWrapper> validDrives = new List <DriveInfoWrapper>();

        System.IO.DriveInfo[] drives = System.IO.DriveInfo.GetDrives();
        foreach (System.IO.DriveInfo di in drives)
        {
            try
            {
                DriveInfoWrapper diw = new DriveInfoWrapper();
                diw.di = di;

                if (di.DriveType == System.IO.DriveType.Removable)
                {
                    try
                    {
                        if (di.VolumeLabel == "SONY" && di.DriveFormat == "FAT32")
                        {
                            diw.isValid = true;
                        }
                        else
                        {
                            if (di.VolumeLabel != "SONY")
                            {
                                diw.message = "Not named SONY";
                            }
                            else
                            {
                                if (di.DriveFormat != "FAT32")
                                {
                                    diw.message = "Not FAT32";
                                }
                            }
                        }
                    }
                    catch (Exception exc)
                    {
                        diw.message = exc.Message;
                    }
                }
                else
                {
                    diw.message = "Not removable";
                }
                validDrives.Add(diw);
            }
            catch (Exception exc)
            {
            }
        }
        return(validDrives);
    }
        /// <summary>
        /// Retrieves the drive names of all logical drives on a computer.
        /// </summary>
        /// <returns>An array of type <see cref="DriveInfoBase"/> that represents the logical drives on a computer.</returns>
        public DriveInfoBase[] GetDrives()
        {
            var driveInfos        = DriveInfo.GetDrives();
            var driveInfoWrappers = new DriveInfoBase[driveInfos.Length];

            for (int index = 0; index < driveInfos.Length; index++)
            {
                var driveInfo = driveInfos[index];
                driveInfoWrappers[index] = new DriveInfoWrapper(fileSystem, driveInfo);
            }

            return(driveInfoWrappers);
        }
        /// <summary>
        /// Retrieves the drive names of all logical drives on a computer.
        /// </summary>
        /// <returns>An array of type <see cref="DriveInfoBase"/> that represents the logical drives on a computer.</returns>
        public IDriveInfo[] GetDrives()
        {
            var driveInfos        = DriveInfo.GetDrives();
            var driveInfoWrappers = new IDriveInfo[driveInfos.Length];

            for (var index = 0; index < driveInfos.Length; index++)
            {
                var driveInfo = driveInfos[index];
                driveInfoWrappers[index] = new DriveInfoWrapper(_fileSystem, driveInfo);
            }

            return(driveInfoWrappers);
        }