예제 #1
0
        public void CopyAll(FileInfo[] sourceFileInfos, Component targetDir)
        {
            string result = "";

            foreach (FileInfo fi in sourceFileInfos)
            {
                Console.WriteLine(fi.FullName);
                Component file = targetDir.GetChild(fi.Name);
                if (file != null)
                {
                    if (file.IsDirectory())
                    {
                        Console.WriteLine("拒绝访问。");
                        continue;
                    }
                    else
                    {
                        if (Logger.ChooseDialogYNA(ref result, "覆盖 {0} 吗?", fi.Name))
                        {
                            file.Remove();
                        }
                        else
                        {
                            continue;
                        }
                    }
                }

                file = new VsFile(fi.Name.Remove(fi.Name.Length - fi.Extension.Length, fi.Extension.Length), fi.Extension);
                (file as VsFile).Read(fi.FullName);
                targetDir.Add(file);
            }
        }
        protected override Status CheckEndPath(ref Component targetDir, ref MString fileName, MString endName, bool usePattern)
        {
            if (targetDir.GetChild(endName) != null)
            {
                return(Status.Error_Path_Already_Exist);
            }

            return(base.CheckEndPath(ref targetDir, ref fileName, endName, usePattern));
        }
예제 #3
0
        public void CopyAllWithChangeExName(FileInfo[] sourceFileInfos, Component targetDir, string lastDestPath)
        {
            string result = "";
            string exName = lastDestPath.Substring(1);

            if (exName == ".")
            {
                exName = "";
            }

            foreach (FileInfo fi in sourceFileInfos)
            {
                Console.WriteLine(fi.FullName);
                string    name = fi.Name.Remove(fi.Name.Length - fi.Extension.Length, fi.Extension.Length) + exName;
                Component file = targetDir.GetChild(name);
                if (file != null)
                {
                    if (file.IsDirectory())
                    {
                        Console.WriteLine("拒绝访问。");
                        continue;
                    }
                    else
                    {
                        if (Logger.ChooseDialogYNA(ref result, "覆盖 {0} 吗?", fi.Name))
                        {
                            file.Remove();
                        }
                        else
                        {
                            continue;
                        }
                    }
                }

                string newExName = "";
                if (name.LastIndexOf('.') != -1)
                {
                    newExName = name.Substring(name.LastIndexOf('.'), name.Length - name.LastIndexOf('.'));
                }
                string newName = name.Remove(name.Length - newExName.Length, newExName.Length);
                file = new VsFile(newName, newExName);
                (file as VsFile).Read(fi.FullName);
                targetDir.Add(file);
            }
        }
예제 #4
0
        public void CopyWithChangeNameAndExName(FileInfo[] sourceFileInfos, Component targetDir, string lastDestPath)
        {
            string result = "";
            string exName = "";

            if (lastDestPath.LastIndexOf('.') != -1)
            {
                exName = lastDestPath.Substring(lastDestPath.LastIndexOf('.'), lastDestPath.Length - lastDestPath.LastIndexOf('.'));
            }
            string    name = lastDestPath.Remove(lastDestPath.Length - exName.Length, exName.Length);
            Component file = targetDir.GetChild(lastDestPath);

            if (file != null)
            {
                if (file.IsDirectory())
                {
                    Console.WriteLine("拒绝访问。");
                    return;
                }
                else
                {
                    if (Logger.ChooseDialogYNA(ref result, "覆盖 {0} 吗?", name))
                    {
                        file.Remove();
                    }
                    else
                    {
                        return;
                    }
                }
            }

            file = new VsFile(name, exName);
            foreach (FileInfo fi in sourceFileInfos)
            {
                Console.WriteLine(fi.FullName);
                (file as VsFile).Read(fi.FullName);
            }
            targetDir.Add(file);
        }