示例#1
0
        public FileOperationResult Rename(FileFolderAction command)
        {
            FileOperationResult rst = new FileOperationResult();
            try
            {
                if (command.isFile)
                {
                    if (File.Exists(command.path))
                    {
                        FileInfo info = new FileInfo(command.path);
                        File.Move(command.path, info.Directory.FullName + "\\" + command.newName);
                    }
                    else
                    {
                        rst.IsSuccess = false;
                        rst.Message = "File Not Exist";

                    }
                }
                else
                {
                    if (Directory.Exists(command.path))
                    {
                        DirectoryInfo info = new DirectoryInfo(command.path);
                        Directory.Move(command.path, info.Parent.FullName + "\\" + command.newName);
                    }
                    else
                    {
                        rst.IsSuccess = false;
                        rst.Message = "Folder Not Exist";

                    }
                }
            }
            catch(Exception e)
            {
                rst.IsSuccess = false;
                rst.Message = e.Message;

            }
            return rst;
        }
示例#2
0
 public FileOperationResult FolderAction(FileFolderAction command)
 {
     FileOperationResult rst = new FileOperationResult();
     if (command.isRemove)
     {
         if (Directory.Exists(command.path))
         {
             try
             {
                 DirectoryInfo di = new DirectoryInfo(command.path);
                 di.Delete(true);
             }
             catch(Exception e)
             {
                 rst.Message =e.Message;
                 rst.IsSuccess = false;
             }
         }
         else
         {
             rst.IsSuccess = false;
             rst.Message = "Folder Not Exist";
         }
     }
     else
     {
         if (Directory.Exists(command.path))
         {
             rst.IsSuccess = false;
             rst.Message = "Folder Already Exist";
         }
         else
         {
             Directory.CreateDirectory(command.path);
         }
     }
     return rst;
 }
示例#3
0
 public ObservableCollection<FileInfoItem> GetFileInfo(FileFolderAction command)
 {
     if (command.isFile)
         return FileVersionHelper.GetFileInfo(command.path);
     else
         return FileVersionHelper.GetFolderInfo(command.path);
 }
示例#4
0
 public FileOperationResult FileAction(FileFolderAction command)
 {
     FileOperationResult rst = new FileOperationResult();
     if (command.isRemove)
     {
         if (File.Exists(command.path))
         {
             try
             {
                 File.Delete(command.path);
                 rst.IsSuccess = true;
             }
             catch (Exception e)
             {
                 rst.Message = e.Message;
                 rst.IsSuccess = false;
             }
         }
         else
         {
             rst.IsSuccess = false;
             rst.Message = "File Not Exist";
         }
     }
     return rst;
 }