Example #1
0
        public static void p5_io_copy_file(ApplicationContext context, ActiveEventArgs e)
        {
            // Checking uf user supplied an [overwrite] argument, and using its value to ignore File.Exists, if supplied.
            var overwrite = e.Args.GetExChildValue("overwrite", context, false);

            e.Args ["overwrite"]?.UnTie();

            // Using our common helper for actual implementation.
            MoveCopyHelper.CopyMoveFileObject(
                context,
                e.Args,
                "read-file",
                "modify-file",
                delegate(string rootFolder, string source, string destination) {
                File.Copy(rootFolder + source, rootFolder + destination);
            },
                delegate(string filename) {
                if (overwrite && File.Exists(filename))
                {
                    File.Delete(filename);
                    return(false);
                }
                return(File.Exists(filename));
            });
        }
Example #2
0
 public static void p5_io_folder_move(ApplicationContext context, ActiveEventArgs e)
 {
     // Using our common helper for actual implementation
     MoveCopyHelper.CopyMoveFileObject(
         context,
         e.Args,
         "modify-folder",
         "modify-folder",
         delegate(string rootFolder, string source, string destination) {
         // Actually moving (or renaming) folder
         Directory.Move(rootFolder + source, rootFolder + destination);
     }, Directory.Exists);
 }
Example #3
0
 public static void p5_io_file_move(ApplicationContext context, ActiveEventArgs e)
 {
     // Using our common helper for actual implementation.
     MoveCopyHelper.CopyMoveFileObject(
         context,
         e.Args,
         "modify-file",
         "modify-file",
         delegate(string rootFolder, string source, string destination) {
         File.Move(rootFolder + source, rootFolder + destination);
     },
         delegate(string destination) {
         return(File.Exists(destination));
     });
 }
Example #4
0
 public static void p5_io_folder_copy(ApplicationContext context, ActiveEventArgs e)
 {
     // Using our common helper for actual implementation.
     MoveCopyHelper.CopyMoveFileObject(
         context,
         e.Args,
         "read-folder",
         "modify-folder",
         delegate(string rootFolder, string source, string destination) {
         CopyFolder(
             context,
             e.Args,
             GetSourceFileObjects(rootFolder + source, ""),
             rootFolder + source,
             rootFolder + destination);
     }, Directory.Exists);
 }