コード例 #1
0
ファイル: Program.cs プロジェクト: FjoNef/GZipTest
        private static int Main(string[] args)
        {
            try
            {
                if (args.Length < 2)
                {
                    Console.WriteLine("Please, use the following parameters: GZipTest.exe compress/decompress input_file_name [output_file_name]");
                    Console.WriteLine("Press <Enter> to exit");
                    Console.ReadLine();
                    return(0);
                }

                string inputFileName  = args[1];
                string outputFileName = null;
                if (args.Length > 2)
                {
                    outputFileName = args[2];
                }

                switch (args[0])
                {
                case "compress":
                    Console.Write("Compressing...   0%");
                    GZipper.Compress(inputFileName, outputFileName);
                    Console.WriteLine("\nCompleted");
                    break;

                case "decompress":
                    Console.Write("Decompressing...   0%");
                    GZipper.Decompress(inputFileName, outputFileName);
                    Console.WriteLine("\nCompleted");
                    break;

                default:
                    Console.WriteLine("Please, use the following parameters: GZipTest.exe compress/decompress input_file_name [output_file_name]");
                    break;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("\nError: {0}", ex.ToString());
                Console.WriteLine("Press <Enter> to exit");
                Console.ReadLine();
                return(1);
            }

            Console.WriteLine("Press <Enter> to exit");
            Console.ReadLine();
            return(0);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: Irbis377/GZipTest
        static int Main(string[] args)
        {
            if (args.Length != 3)
            {
                ShowInfo();
                Console.Read();

                return(-1);
            }

            CompressionMode mode = CompressionMode.Compress; //init

            try
            {
                Validation.StringReadValidation(args);

                switch (args[0].ToLower())
                {
                case "compress":
                    mode   = CompressionMode.Compress;
                    zipper = new Compressor(args[1], args[2]);
                    break;

                case "decompress":
                    mode   = CompressionMode.Decompress;
                    zipper = new Decompressor(args[1], args[2]);
                    break;
                }
                zipper.Process(mode); //all magic here!

                Console.WriteLine("Done!");

                Console.Read();
                return(0);
            }

            catch (Exception ex)
            {
                Console.WriteLine("Error is occured!\n Method: {0}\n Error description {1}", ex.TargetSite, ex.Message);
                Console.Read();
                return(1);
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: GKapelan/GZipProject
        static void Main(string[] args)
        {
            Console.WriteLine("How to: GZipTest command input_file output_file");
            Console.WriteLine("Possible commands: compress/decompress");
            Console.WriteLine("-----------------------------------------------\n");

            try
            {
                ChkCmdLine(args);

                String command    = args[0]; // type
                String inputFile  = args[1]; // input file for comp/decomp
                String outputFile = args[2]; // output file

                Console.WriteLine("Command:         " + command);
                Console.WriteLine("Input File:      " + inputFile);
                Console.WriteLine("Output File:     " + outputFile);

                if (command.ToLower().Equals("compress"))
                {
                    gzipper = new Compression(inputFile, outputFile);
                }
                if (command.ToLower().Equals("decompress"))
                {
                    gzipper = new Decompression(inputFile, outputFile);
                }

                gzipper.Execute();
            }
            catch (Exception e)
            {
                Console.WriteLine("Error! " + e.Message + "\nPress any key ... ");
            }

            Console.ReadKey();
        }