示例#1
0
文件: Program.cs 项目: byzod/C-Sharp
        //静态方法。文件移动操作
        public static void MoveFile(DirectoryInfo srcPath, string desPath)
        {
            //获取文件列表
            FileInfo[] srcFiles = srcPath.GetFiles();

            foreach (FileInfo srcFile in srcFiles)
            {
                if (!File.Exists(desPath + "\\" + Path.GetFileNameWithoutExtension(srcFile.FullName) + srcFile.Extension))
                {
                    //无冲突则直接移动
                    Mov(srcFile, desPath, MoveMethod.Dirc);
                }
                else
                {
                    if (AllRename == true) Mov(srcFile, desPath, MoveMethod.Ren);
                    else if (AllOverR == true) Mov(srcFile, desPath, MoveMethod.OverR);
                    else if (AllSkip == true) ;
                    //弹出询问对话框
                    else
                    {
                        MoveMethodChose alertbox = new MoveMethodChose(srcFile.Name, true);
                        alertbox.ShowDialog();
                        switch (alertbox.movemethod)
                        {
                            case MoveMethod.OverR:
                                Mov(srcFile, desPath, MoveMethod.OverR);
                                break;
                            case MoveMethod.Ren:
                                Mov(srcFile, desPath, MoveMethod.Ren);
                                break;
                            case MoveMethod.None:
                                break;
                        }
                    }
                }
            }
        }
示例#2
0
文件: Program.cs 项目: byzod/C-Sharp
        //静态方法。目录移动操作
        public static void MoveDirc(DirectoryInfo srcPath, string desPath)
        {
            //获取目录列表
            DirectoryInfo[] srcDircs = srcPath.GetDirectories();

            foreach (DirectoryInfo srcDirc in srcDircs)
            {
                string debug = desPath + "\\" + srcDirc.Name;
                if (!Directory.Exists(desPath + "\\" + srcDirc.Name))
                {
                    //无冲突则直接移动
                    Mov(srcDirc, desPath, MoveMethod.Dirc);
                }
                else
                {
                    if (AllRename_D == true) Mov(srcDirc, desPath, MoveMethod.Ren);
                    //合并
                    else if (AllOverR_D == true) Mov(srcDirc, desPath, MoveMethod.OverR);
                    else if (AllSkip_D == true) ;
                    //弹出询问对话框
                    else
                    {
                        MoveMethodChose alertbox = new MoveMethodChose(srcDirc.Name, false);
                        alertbox.ShowDialog();
                        switch (alertbox.movemethod)
                        {
                            case MoveMethod.OverR:
                                Mov(srcDirc, desPath, MoveMethod.OverR);
                                break;
                            case MoveMethod.Ren:
                                Mov(srcDirc, desPath, MoveMethod.Ren);
                                break;
                            case MoveMethod.None:
                                break;
                        }
                    }
                }
            }
        }