Exemplo n.º 1
0
        protected override void Execute(NativeActivityContext context)
        {
            try
            {
                string SourcePath      = FolderPath.Get(context);
                string DestinationPath = CopyPath.Get(context);
                string DestFolder      = Path.GetFileName(SourcePath);
                DestinationPath = DestinationPath + "\\" + DestFolder;


                if (Directory.Exists(SourcePath))
                {
                    if (isOverride == true && Directory.Exists(DestinationPath))
                    {
                        Directory.Delete(DestinationPath, true);
                    }
                    else if (isOverride == false && Directory.Exists(DestinationPath))
                    {
                        throw new Exception("File with the same name already exist - " + DestinationPath);
                    }

                    if (!Directory.Exists(DestinationPath))
                    {
                        Directory.CreateDirectory(DestinationPath);
                    }



                    //Now Create all of the directories
                    foreach (string dirPath in Directory.GetDirectories(SourcePath, "*",
                                                                        SearchOption.AllDirectories))
                    {
                        Directory.CreateDirectory(dirPath.Replace(SourcePath, DestinationPath));
                    }

                    //Copy all the files & Replaces any files with the same name
                    foreach (string newPath in Directory.GetFiles(SourcePath, "*.*",
                                                                  SearchOption.AllDirectories))
                    {
                        File.Copy(newPath, newPath.Replace(SourcePath, DestinationPath), true);
                    }
                }
                else if (!Directory.Exists(SourcePath))
                {
                    Log.Logger.LogData("Folder does not exist in path - " + SourcePath + " in activity Folder_Copy", LogLevel.Error);
                    if (!ContinueOnError)
                    {
                        context.Abort();
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Logger.LogData(ex.Message + " in activity Folder_Copy", LogLevel.Error);
                if (!ContinueOnError)
                {
                    context.Abort();
                }
            }
        }
Exemplo n.º 2
0
 public void CopyImage(string fileToCopy, string fileName = "")
 {
     //Need to check if already exists i.e if want to generate again
     if (File.Exists(fileToCopy))
     {
         if (Directory.Exists(CopyPath))
         {
             var newFileName = String.IsNullOrEmpty(fileName) ? Path.GetFileName(fileToCopy) : fileName + Path.GetExtension(fileToCopy);
             var newfile     = CopyPath + newFileName;
             // Copies files to location and will override if already exists
             // won't release the file handle until the application has been closed
             // Explore other options to allow to close file
             File.Copy(fileToCopy, newfile, true);
             FilePath  = newfile;
             ImagePath = CopyPath.Substring(CopyPath.IndexOf("\\images\\"));
             ImagePath = ImagePath + Path.GetFileName(newfile);
         }
         else
         {
             Error = "Directory to copy to does not exist";
         }
     }
     else
     {
         Error = "File to copy does not exist";
     }
 }
Exemplo n.º 3
0
        private ToolStripMenuItem CreateCopyPathMenuItem(ToolStripMenuItem toolStripMenuItem, string menuType, string clickedItemPath)
        {
            var copyPath = new CopyPath();
            var escapedFilePathMenuItem = copyPath.CreateToolStripMenuItem(menuType, clickedItemPath, true);

            toolStripMenuItem.DropDownItems.Add(escapedFilePathMenuItem);

            var copyPathMenuItem = copyPath.CreateToolStripMenuItem(menuType, clickedItemPath);

            toolStripMenuItem.DropDownItems.Add(copyPathMenuItem);

            return(toolStripMenuItem);
        }
Exemplo n.º 4
0
 static void CopyNodePath()
 {
     CopyPath.CopyNodePath();
 }