Exemplo n.º 1
0
        /// <summary>
        ///     Main Entry Point
        /// </summary>
        /// <param name="args">
        ///     NameValuepair containing all options:
        ///         FILENAME, CHUNKSIZE, ACTION
        /// </param>
        public static void Main(string[] args)
        {
            NameValuePair nvp = new NameValuePair(Environment.CommandLine);

            string strFileName = nvp["FILENAME"];
            string strChunkSize = nvp["CHUNKSIZE"];

            if (strFileName == string.Empty)
            {   // No filename specified

                Console.WriteLine("ERROR: FileName not specified.");
                HowDoIUseThis();

            }   // No filename specified
            else
            {   // Filename specified

                if (nvp["ACTION"] == "COMBINE")
                {   // Combine

                    CombineFiles(strFileName);

                }   // Combine
                else
                {   // Split

                    if (!System.IO.File.Exists(strFileName))
                    {   // Inputfile does not exist

                        Console.WriteLine("ERROR: Input file does not exist.");
                        HowDoIUseThis();

                    }   // Inputfile does not exist
                    else
                    {   // Input File Exists

                        if (string.IsNullOrEmpty(strChunkSize))
                        {   // No chunksize specified

                            strChunkSize = "5MB";

                        }   // No chunksize specified

                        long chunkSize = GetBytes(strChunkSize);

                        if (chunkSize == -1)
                        {   // Split by Unknown Chunk Size

                            Console.WriteLine("ERROR: Chunksize invalid or not specified");
                            HowDoIUseThis();

                        }   // Split by Unknown Chunk Size
                        else
                        {   // ChunkSize specified

                            SplitFile(strFileName, chunkSize);

                        }   // ChunkSize specified

                    }   // Input File Exists

                }   // Split

            }   // Filename specified
        }