Example #1
0
        public override object EXECUTE(params object[] po)
        {
            var copy = new COPY();

            copy._append                       = _append;
            copy._copysubdirectory             = _copysubdirectory;
            copy._create                       = _create;
            copy._nocreatedestinationdirectory = _nocreatedestinationdirectory;
            copy._serialize                    = _serialize;
            copy.main(po);
            if (po != null && po.Length > 0)
            {
                try
                {
                    string s  = PATH.getpath(source.ToString().Trim());
                    bool   sf = PATH.isfile(s);
                    if (!sf)
                    {
                        Directory.Delete(s, _copysubdirectory);//delete directory to directory
                    }
                    else
                    {
                        File.Delete(s);
                    }
                }
                catch { }
            }
            return(po);
        }
Example #2
0
        public override object execute(object obj, int index, int length)
        {
            FileMode f = (_create) ? FileMode.OpenOrCreate : FileMode.Open;

            if (index == 0)
            {
                source = obj;
            }
            else if (obj != null && obj is string)
            {
                if (source != null && source is string)
                {
                    string s  = PATH.getpath(source.ToString().Trim());
                    string d  = PATH.getpath(obj.ToString().Trim());
                    bool   sf = PATH.isfile(s);
                    bool   df = PATH.isfile(d);
                    if (!df && !_nocreatedestinationdirectory)
                    {
                        MiMFa_Path.CreateAllDirectories(d);
                    }
                    if (!df && !sf)
                    {
                        MiMFa_Path.DirectoryCopy(s, d, _copysubdirectory);//copy directory to directory
                    }
                    else if (!df && sf)
                    {
                        File.Copy(s, d + Path.GetFileName(s));
                    }
                    else if (df && !sf)
                    {
                        throw new ArgumentException("Can not copy a directory in file!");
                    }
                    else
                    {
                        File.Copy(s, d);
                    }
                }
                else if (source != null)
                {
                    if (_serialize)
                    {
                        MiMFa_IOService.SaveSerializeFile(obj.ToString(), source, f);
                    }
                    else if (_append)
                    {
                        MiMFa_IOService.StringNewLineAppendFile(obj.ToString(), MCL.Display.Done(source), f);
                    }
                    else
                    {
                        MiMFa_IOService.StringToFile(obj.ToString(), MCL.Display.Done(source), f);
                    }
                }
                else
                {
                    throw new ArgumentNullException("Can not be null sources!");
                }
            }
            else
            {
                obj = source;
            }
            return(Null);
        }