Пример #1
0
        public Search CreateModel(string path)
        {
            // DirectoryInfo di = new DirectoryInfo(directory);
            //long count = di.GetFiles("",SearchOption.AllDirectories).Where(f => f.Length < fileSize).Count();
            Search model = new Search();
            model.CurrentPath = path;
            model.currendDirInfo.Files = new List<FileFromDirectory>();
            DirectoryInfo dir = new DirectoryInfo(path);//dir = dir.parent is it a catalog?
            model.currendDirInfo.ParentFolder = new FileFromDirectory();
            model.currendDirInfo.ParentFolder.FullName = dir.Parent != null ? dir.Parent.FullName : null;
            model.currendDirInfo.ParentFolder.Name = "..";
            model.BaseFolder = new FileFromDirectory();
            model.BaseFolder.FullName = "...";
            model.BaseFolder.Name = "...";
            model.currendDirInfo.NumberOfFiles = new NumberOfFiles();
            if (File.Exists(path))
                model.currendDirInfo.CurrendDir = dir.Parent.FullName;
            else
                model.currendDirInfo.CurrendDir = dir.FullName;
            model.currendDirInfo.NumberOfFiles = new NumberOfFiles();
            CheckAllDirectories(dir.FullName, model.currendDirInfo.NumberOfFiles);

            model.currendDirInfo.Files = GetFilesFromDirectory(model.currendDirInfo.CurrendDir);
            model.currendDirInfo.Directories = GetSubdirectoriesFromDirectory(model.currendDirInfo.CurrendDir);
            return model;
        }
Пример #2
0
 public Search GetLogicalDriversModel()
 {
     Search model = new Search();
     model.CurrentPath = "...";
     model.BaseFolder = new FileFromDirectory();
     model.currendDirInfo.ParentFolder = new FileFromDirectory();
     List<FileFromDirectory> logicalDrivers = new List<FileFromDirectory>();
     foreach (string logicalDisk in Directory.GetLogicalDrives())
     {
         DirectoryInfo di = new DirectoryInfo(logicalDisk);
         logicalDrivers.Add(new FileFromDirectory() { FullName = di.FullName, Name = di.Name });
     }
     model.currendDirInfo.Directories = logicalDrivers;
     return model;
 }