Exemple #1
0
        static void Main(string[] args)
        {
            var commandLineParameters = new OperationCommand();
            var compressor            = new Compressor();

            try
            {
                commandLineParameters.ProcessCommandParameters(args);

                switch (commandLineParameters.Operation)
                {
                case OperationKind.Compress:
                {
                    compressor.Compress(commandLineParameters.SourceFilePath, commandLineParameters.TargetFilePath);
                    break;
                }

                case OperationKind.Decompress:
                {
                    compressor.Decompress(commandLineParameters.SourceFilePath, commandLineParameters.TargetFilePath);
                    break;
                }

                default:
                {
                    throw new ArgumentException($"Unsupported command {commandLineParameters.Operation}.");
                }
                }
            }

            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Exemple #2
0
        static int Main(string[] args)
        {
            string command = (args.Length > 1) ? args[0] : "compress";
            string source  = (args.Length > 1) ? args[1] : "C:\\Test\\backup.sql";
            string target  = (args.Length > 1) ? args[2] : "C:\\Test\\split\\backup2.zip";


            using (var compressor = new Compressor(source, target))
            {
                if (command.Equals("compress"))
                {
                    if (compressor.Compress())
                    {
                        return(0);
                    }
                    return(1);
                }

                if (command.Equals("decompress"))
                {
                    if (compressor.Decompress())
                    {
                        return(0);
                    }
                    return(1);
                }

                Console.WriteLine("Unknown command.");
                return(1);
            }
        }