示例#1
0
        private void AddFiles(string driveUnitLetter, IsoFolder currentFolder, FileScanResult fileScanResult, IsoVolume iso)
        {
            string[] filePaths;

            try
            {
                filePaths = DirectoryProvider.GetFiles(currentFolder.Path.Replace("/", driveUnitLetter + @":\"), "*.*");
                fileScanResult.ProcessedFolderCount += 1;
            }
            catch (UnauthorizedAccessException)
            {
                fileScanResult.Log.AppendLine(string.Format("ERROR folder-access rights-:'{0}'", currentFolder.Path));
                fileScanResult.FoldersWithErrorCount += 1;
                return;
            }
            catch (Exception)
            {
                fileScanResult.Log.AppendLine(string.Format("ERROR folder-unknown-:'{0}'", currentFolder.Path));
                fileScanResult.FoldersWithErrorCount += 1;
                return;
            }

            foreach (var filePath in filePaths)
            {
                IsoFile isoFile;
                try
                {
                    isoFile             = FileProvider.GetIsoFile(filePath);
                    isoFile.IsoVolumeId = iso.Id;
                }
                catch (UnauthorizedAccessException)
                {
                    fileScanResult.Log.AppendLine(string.Format("ERROR file-access rights-:'{0}'", filePath));
                    fileScanResult.FilesWithErrorCount += 1;
                    continue;
                }
                catch (Exception)
                {
                    fileScanResult.Log.AppendLine(string.Format("ERROR file-unknown-:'{0}'", filePath));
                    fileScanResult.FilesWithErrorCount += 1;
                    continue;
                }

                isoFile.Parent = currentFolder;
                fileScanResult.ProcessedFileCount += 1;
                currentFolder.ChildFiles.Add(isoFile);

                fileScanResult.Log.AppendLine(
                    string.Format(
                        "FILE name:'{0}', extension:'{1}', path:'{2}', dateCreated:{3}, dateModified:{4}, size:{5}",
                        isoFile.Name,
                        isoFile.Extension,
                        filePath,
                        isoFile.Created,
                        isoFile.Modified,
                        GetSizeString(isoFile.Size)
                        ));
            }
        }
示例#2
0
        private void AddFolders(string driveUnitLetter, IsoFolder currentFolder, List <IsoFolder> folders, IsoVolume iso)
        {
            var folderPaths = DirectoryProvider.GetDirectories(currentFolder.Path.Replace("/", driveUnitLetter + @":\"));

            foreach (var path in folderPaths)
            {
                var childFolder = new IsoFolder
                {
                    Name        = Path.GetFileName(path),
                    Path        = path,
                    Parent      = currentFolder,
                    IsoVolumeId = iso.Id
                };
                childFolder.Path = childFolder.Path.Replace(driveUnitLetter + @":\", "/");
                currentFolder.ChildFolders.Add(childFolder);
                folders.Add(childFolder);
            }
        }