bool OnAllowMediaStorage(StorageVolumeInfo info)
        {
            AllowStorageEventArgs e = new AllowStorageEventArgs(info);

            RaiseAllowStorage(e);
            return(e.Allow);
        }
 private bool CheckIsDeviceAlreadyAdded(StorageVolumeInfo volume)
 {
     foreach (StorageVolumeInfo v in StorageManager.Default.Storage)
     {
         if (v.Device.SerialNumber == volume.Device.SerialNumber)
         {
             if (StorageManager.Default.DialogsProvider.DisplayThisStorageNotRecommendedForAddBecauseAlreadyUsed() == DialogResult.OK)
             {
                 return(false);
             }
             return(true);
         }
     }
     foreach (StorageVolumeInfo v in StorageManager.Default.Backup)
     {
         if (v.Device.SerialNumber == volume.Device.SerialNumber)
         {
             if (StorageManager.Default.DialogsProvider.DisplayThisStorageNotRecommendedForAddBecauseAlreadyUsed() == DialogResult.OK)
             {
                 return(false);
             }
             return(true);
         }
     }
     return(false);
 }
 private bool CheckIsVolumeCorrect(StorageVolumeInfo volume, string root)
 {
     if (volume == null)
     {
         StorageManager.Default.DialogsProvider.DisplayVolumeIsNotCorrect(root);
         return(false);
     }
     return(true);
 }
        public static GalleryItem CreateItem(StorageVolumeInfo info)
        {
            GalleryItem item = new GalleryItem();

            item.Caption     = info.VolumeLabel + " - " + info.ActualName + " - " + info.ProjectFolder;
            item.Description = FileSizeHelper.Size2String(info.AvailableFreeSpace) + "/" + FileSizeHelper.Size2String(info.TotalFreeSpace) + "  " + info.Device.ProductId;
            item.Image       = GetImage(info);
            item.Tag         = info;
            return(item);
        }
        public override FileInfo CopyFile(string file, StorageVolumeInfo volume, string relativePath, bool isBackup)
        {
            const int ERROR_DISK_FULL = 0x70;

            if (isBackup)
            {
                if (RaiseBackupFullExceptionCount > 0)
                {
                    RaiseBackupFullExceptionCount--;
                    throw new IOException(string.Empty, ERROR_DISK_FULL);
                }
                else if (RaiseBackupIoExceptionCount > 0)
                {
                    RaiseBackupIoExceptionCount--;
                    throw new IOException(string.Empty, 0);
                }
                else if (RaiseBackupUnatorizedExceptionCount > 0)
                {
                    RaiseBackupUnatorizedExceptionCount--;
                    throw new UnauthorizedAccessException();
                }
            }
            else
            {
                if (RaiseStorageFullExceptionCount > 0)
                {
                    RaiseStorageFullExceptionCount--;
                    throw new IOException(string.Empty, ERROR_DISK_FULL);
                }
                else if (RaiseIoExceptionCount > 0)
                {
                    RaiseIoExceptionCount--;
                    throw new IOException(string.Empty, 0);
                }
                else if (RaiseUnatorizedExceptionCount > 0)
                {
                    RaiseUnatorizedExceptionCount--;
                    throw new UnauthorizedAccessException();
                }
            }
            string fileName = "c:\\temp\\" + Guid.NewGuid() + " - testFile.txt";

            if (!Directory.Exists("c:\\temp\\"))
            {
                Directory.CreateDirectory("c:\\temp");
            }

            File.Create(fileName);
            return(new FileInfo(fileName));
        }
        private void CheckAddStorageDevice(string root, string relativePath)
        {
            StorageVolumeInfo volume = StorageManager.Default.GetStorageVolumeInfo(root);

            volume.ProjectFolder = relativePath;
            if (!CheckIsVolumeCorrect(volume, root))
            {
                return;
            }
            if (CheckIsDeviceAlreadyAdded(volume))
            {
                return;
            }
            DataSource.Add(volume);
        }
 protected override long GetAvailableFreeSpace(StorageVolumeInfo volume) => volume.AvailableFreeSpace;
 private static Image GetImage(StorageVolumeInfo info)
 {
     return(null);
 }