Beispiel #1
0
 public void Copy(string dest)
 {
     if (dest.Contains(Path))
     {
         MessageView.FolderCopyError(Path);
         return;
     }
     try
     {
         DirectoryInfo currentDirectory = new DirectoryInfo(Path);
         dest = dest + @"\" + Name;
         if (!Directory.Exists(dest))
             Directory.CreateDirectory(dest);
         foreach (DirectoryInfo dir in currentDirectory.GetDirectories())
         {
             if (!Directory.Exists(dest + @"\" + dir.Name))
                 Directory.CreateDirectory(dest + @"\" + dir.Name);
             Folder currentFolder = new Folder(dir.Name, dir.FullName, null);
             currentFolder.Copy(dest);
         }
         foreach (FileInfo file in currentDirectory.GetFiles())
         {
             File currentFile = new File(System.IO.Path.GetFileNameWithoutExtension(file.Name),
                 file.FullName, file.Extension, file.Length, null);
             currentFile.Copy(dest);
         }
     }
     catch (IOException)
     {
         MessageView.FolderCopyError(Path);
     }
 }
Beispiel #2
0
 public void CopyClipboard(string[] elements, string dest)
 {
     if (OpenedElement == null || elements == null)
         return;
     foreach (string element in elements)
     {
         if(Directory.Exists(element))
         {
             Folder currentFolder = new Folder(Path.GetFileName(element), element, null);
             currentFolder.Copy(dest);
         }
         else if (System.IO.File.Exists(element))
         {
             FileInfo file = new FileInfo(element);
             File currentFile = new File(Path.GetFileNameWithoutExtension(file.Name),
                 file.FullName, file.Extension, file.Length, null);
             currentFile.Copy(dest);
         }
     }
 }
Beispiel #3
0
 public void GoPath(string path)
 {
     if (string.IsNullOrEmpty(path) || OpenedElement.Path == path)
         return;
     if(Path.GetPathRoot(path) == path && (new DriveInfo(path).IsReady))
     {
         var openedDriveInfo = new DriveInfo(path);
         var openedElement = new Disk(openedDriveInfo.Name,
             openedDriveInfo.Name,
             openedDriveInfo.DriveType,
             OpenedElement);
         if (UpdateField(openedElement))
             OpenedElement = openedElement;
     }
     else if (Directory.Exists(path))
     {
         var openedDirectoryInfo = new DirectoryInfo(path);
         var openedElement = new Folder(openedDirectoryInfo.Name,
             openedDirectoryInfo.FullName,
             OpenedElement);
         if (UpdateField(openedElement))
             OpenedElement = openedElement;
     }
     else if(System.IO.File.Exists(path))
     {
         var openedFileInfo = new FileInfo(path);
         var openedElement = new File(
             openedFileInfo.Name,
             openedFileInfo.FullName,
             openedFileInfo.Extension,
             openedFileInfo.Length,
             OpenedElement);
         if (UpdateField(openedElement))
             OpenedElement = openedElement;
     }
 }
Beispiel #4
0
 public bool Remove()
 {
     try
     {
         DirectoryInfo currentDirectory = new DirectoryInfo(Path);
         foreach (DirectoryInfo dir in currentDirectory.GetDirectories())
         {
             Folder currentFolder = new Folder(dir.Name, dir.FullName, null);
             currentFolder.Remove();
         }
         foreach (FileInfo file in currentDirectory.GetFiles())
         {
             File currentFile = new File(System.IO.Path.GetFileNameWithoutExtension(file.Name),
                 file.FullName, file.Extension, file.Length, null);
             currentFile.Remove();
         }
         currentDirectory.Delete();
         return true;
     }
     catch (IOException)
     {
         MessageView.FolderRemoveError(Path);
         return false;
     }
 }