Esempio n. 1
0
        static void Main(string[] args)
        {
            //参数c表示压缩,d表示接压缩,r表示处理后移除原始文件
            if (args.Length != 2)
            {
                PrintUseage();
                return;
            }

            string option = args[0];
            string path   = args[1];

            bool isCompress = option.Contains("c");
            bool removeFile = option.Contains("r");

            ZarcCompress zc = new ZarcCompress();

            bool isFile      = File.Exists(path);
            bool isDirectory = false;

            if (!isFile)
            {
                isDirectory = Directory.Exists(path);
            }

            if (!isFile && !isDirectory)
            {
                Console.WriteLine("指定的路径或文件名不存在\r\n按任意键退出");
                Console.ReadKey();
                return;
            }

            if (isFile)
            {
                if (isCompress)
                {
                    zc.Zip(path, removeFile);
                }
                else
                {
                    zc.Unzip(path, removeFile);
                }
            }
            else
            {
                //批量处理
                DirectoryInfo directory = new DirectoryInfo(path);

                if (isCompress)
                {
                    string[] allFiles = GetAllPrepareFiles(directory);
                    foreach (string file in allFiles)
                    {
                        zc.Zip(file, removeFile);
                    }
                }
                else
                {
                    string[] allFiles = GetAllZarcFiles(directory);
                    foreach (string file in allFiles)
                    {
                        zc.Unzip(file, removeFile);
                    }
                }
            }

            Console.WriteLine("处理完毕\r\n按任意键退出");
            Console.ReadKey();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            //参数c表示压缩,d表示接压缩,r表示处理后移除原始文件
            if (args.Length != 2)
            {
                PrintUseage();
                return;
            }

            string option = args[0];
            string path = args[1];

            bool isCompress = option.Contains("c");
            bool removeFile = option.Contains("r");

            ZarcCompress zc = new ZarcCompress();

            bool isFile = File.Exists(path);
            bool isDirectory = false;
            if (!isFile)
                isDirectory = Directory.Exists(path);

            if (!isFile && !isDirectory)
            {
                Console.WriteLine("指定的路径或文件名不存在\r\n按任意键退出");
                Console.ReadKey();
                return;
            }

            if (isFile)
            {
                if (isCompress)
                {
                    zc.Zip(path, removeFile);
                }
                else
                {
                    zc.Unzip(path, removeFile);
                }
            }
            else
            {
                //批量处理
                DirectoryInfo directory = new DirectoryInfo(path);

                if (isCompress)
                {
                    string[] allFiles = GetAllPrepareFiles(directory);
                    foreach (string file in allFiles)
                    {
                        zc.Zip(file, removeFile);
                    }
                }
                else
                {
                    string[] allFiles = GetAllZarcFiles(directory);
                    foreach (string file in allFiles)
                    {
                        zc.Unzip(file, removeFile);
                    }
                }

            }

            Console.WriteLine("处理完毕\r\n按任意键退出");
            Console.ReadKey();
        }