Ejemplo n.º 1
0
 public FileOnList(string path)
 {
     this.FullPath  = path;
     this.Name      = path.Split('\\').Last();
     this.Date      = File.GetCreationTime(path);
     this.Attribute = File.GetAttributes(this.FullPath);
     if (this.Attribute == FileAttributes.Directory)
     {
         this.IsDirectory = true;
     }
     else
     {
         this.IsDirectory = false;
     }
     if (this.IsDirectory)
     {
         MyDir tmp = new MyDir(this.FullPath, true);
         this.Size = tmp.Size;
     }
     else
     {
         MyFile tmp = new MyFile(this.FullPath);
         this.Size = tmp.Size;
     }
 }
Ejemplo n.º 2
0
        public static IEnumerable <FileOnList> GetDirectoryContent(string directoryPath, Enums.ComparisonType compType = Enums.ComparisonType.Default)
        {
            MyDir             tmp         = new MyDir(directoryPath, true);
            List <FileOnList> discObjList = new List <FileOnList>();

            foreach (DiscObj discObj in tmp.Content)
            {
                discObjList.Add(new FileOnList(discObj.Path));
            }
            return(discObjList);
        }
Ejemplo n.º 3
0
 public MyDir LoadDir()
 {
     while (true)
     {
         try
         {
             string a = Console.ReadLine();
             MyDir  x = new MyDir(a);
             Console.WriteLine("dir loaded");
             return(x);
         }
         catch (Exception)
         {
             Console.WriteLine("bad path");
         }
     }
 }
Ejemplo n.º 4
0
 public static void CopyFiles(IEnumerable <string> srcPaths, string dstPath)
 {
     foreach (string path in srcPaths)
     {
         FileAttributes attribute = File.GetAttributes(path);
         if ((attribute & FileAttributes.Directory) == FileAttributes.Directory)
         {
             MyDir tmpDir = new MyDir(path, true);
             Directory.CreateDirectory(Path.Combine(dstPath, tmpDir.Path.Split('\\').Last()));
             List <string> reqList = new List <string>();
             foreach (DiscObj discObj in tmpDir.Content)
             {
                 reqList.Add(discObj.Path);
                 CopyFiles(reqList, Path.Combine(dstPath, discObj.Path.Split('\\').Last()));
             }
         }
         else
         {
             MyFile tmpFile = new MyFile(path);
             File.Create(Path.Combine(dstPath, tmpFile.Path.Split('\\').Last())).Dispose();
             File.Copy(path, Path.Combine(dstPath, tmpFile.Path.Split('\\').Last()), true);
         }
     }
 }