public BackupFolder(string path, backupType type)
        {
            Path = path;
            Type = type;

            Files = new List<BackupFile>();
            List<FileInfo> fileInfos = new List<FileInfo>();
            DirectoryInfo info = new DirectoryInfo(Path);

            // Converts .GetFiles() to a list
            fileInfos = info.GetFiles().Select(x => x).ToList();

            // Creates BackupFile objects
            foreach (FileInfo fileInfo in fileInfos)
            {
                switch (Type)
                {
                    case backupType.full:
                        FullBackupFile fullBackFile = new FullBackupFile(fileInfo);
                        Files.Add(fullBackFile);
                        break;
                    case backupType.diff:
                        DiffBackupFile diffBackFile = new DiffBackupFile(fileInfo);
                        Files.Add(diffBackFile);
                        break;
                    case backupType.log:
                        LogBackupFile logBackFile = new LogBackupFile(fileInfo);
                        Files.Add(logBackFile);
                        break;
            }
            }
        }
示例#2
0
        public BackupFolder(string path, backupType type)
        {
            Path = path;
            Type = type;

            Files = new List <BackupFile>();
            List <FileInfo> fileInfos = new List <FileInfo>();
            DirectoryInfo   info      = new DirectoryInfo(Path);

            // Converts .GetFiles() to a list
            fileInfos = info.GetFiles().Select(x => x).ToList();

            // Creates BackupFile objects
            foreach (FileInfo fileInfo in fileInfos)
            {
                switch (Type)
                {
                case backupType.full:
                    FullBackupFile fullBackFile = new FullBackupFile(fileInfo);
                    Files.Add(fullBackFile);
                    break;

                case backupType.diff:
                    DiffBackupFile diffBackFile = new DiffBackupFile(fileInfo);
                    Files.Add(diffBackFile);
                    break;

                case backupType.log:
                    LogBackupFile logBackFile = new LogBackupFile(fileInfo);
                    Files.Add(logBackFile);
                    break;
                }
            }
        }
 public BackupFile(backupType type, FileInfo file)
 {
     Name = file.Name;
     Path = file.DirectoryName;
     LastModified = file.LastWriteTime;
     BackupType = type;
     Size = file.Length;
     DatabaseName = Regex.Split(Name, "_backup_")[0];
     FileExtension = file.Extension;
 }
        public BackupFolder(string path, backupType type)
        {
            List<FileInfo> fileInfos = new List<FileInfo>();
            Files = new List<BackupFile>();

            Path = path;
            Type = type;

            info = new DirectoryInfo(Path);

            fileInfos = info.GetFiles().Select(x => x).ToList();
            foreach (FileInfo fileInfo in fileInfos)
            {
                BackupFile bakFile = new BackupFile(Type, fileInfo);
                Files.Add(bakFile);
            }
        }