/// <summary> /// 主程序入口。 /// </summary> /// <param name="args">命令行参数。</param> public static void Main(string[] args) { var options = new Options(); if (Parser.Default.ParseArguments(args, options)) { if (options.Verbose) { Output(options); } try { if (options.Operation.StartsWith("s", StringComparison.InvariantCultureIgnoreCase)) { // 拆分文件。 if (File.Exists(options.InputFilePath)) { var size = GetValue(options.SplitFileSize); var split = new SplitFile(options.InputFilePath, options.OutputFileDir, size); split.Process(); Console.WriteLine("Split '{0}' file completed.", options.InputFilePath); } else { Console.WriteLine("File '{0}' not found.", options.InputFilePath); } } else if (options.Operation.StartsWith("j", StringComparison.InvariantCultureIgnoreCase)) { // 合并文件。 var join = new JoinFile(options.InputFilePath); join.Process(); Console.WriteLine("Join '{0}' file completed.", options.InputFilePath); } else if (options.Operation.StartsWith("c", StringComparison.InvariantCultureIgnoreCase)) { // 验证文件。 if (File.Exists(options.InputFilePath)) { var size = GetValue(options.SplitFileSize); var split = new SplitFile(options.InputFilePath, options.OutputFileDir, size); split.Process(); Console.WriteLine("Check '{0}' file completed.", options.InputFilePath); } else { Console.WriteLine("File '{0}' not found.", options.InputFilePath); } } else if (options.Operation.StartsWith("u", StringComparison.InvariantCultureIgnoreCase)) { // 上传文件。 Console.WriteLine("Upload"); } else if (options.Operation.StartsWith("d", StringComparison.InvariantCultureIgnoreCase)) { // 下载文件。 Console.WriteLine("Download"); } } catch (Exception ex) { Output(ex); } } Console.ReadKey(); }