static void Main(string[] args) { ArgumentValidator argValidator = new ArgumentValidator(); try { // Validate the arguments length is right. argValidator.ValidateLength(args); // Validate the argument is not null or whitespace. String path = args[0]; argValidator.ValidateNull(path); // Check if a Path is a File or a Direcory. // Check a Path is accessible or not. argValidator.ValidatePath(path); argValidator.Dispose(); // Check existence of files in the directory. if (!ExcelUtils.Exists(path)) { throw new Exception("指定されたパスに拡張子.xls? のファイルが見つかりませんでした。"); } String outputfullname = Path.Combine(Directory.GetCurrentDirectory(), DateTime.Now.ToString("yyyyMMddHHmmss") + ".csv"); using (StreamWriter writer = new StreamWriter(outputfullname, false, new UTF8Encoding(true))) { String header = "\"fullname\",\"md5\""; writer.WriteLine(header); StringBuilder sBuilder = new StringBuilder(1024); String quote = "\""; String intermediate = "\",\""; foreach (KeyValuePair <String, String> item in ExcelUtils.SortedFileHashes(path)) { sBuilder.Append(quote); sBuilder.Append(item.Key); sBuilder.Append(intermediate); sBuilder.Append(item.Value); sBuilder.Append(quote); writer.WriteLine(sBuilder.ToString()); sBuilder.Clear(); } } } catch (ArgumentException e) { Console.WriteLine(e.Message); Console.WriteLine(argValidator.ArgumentRequirement); argValidator.Dispose(); Environment.Exit(1); } catch (Exception e) { Console.WriteLine(e.Message); Environment.Exit(1); } }