public static string run(Arguments args) { string ErrorMessage = string.Empty; System.IO.DirectoryInfo directory; System.IO.FileInfo[] filesList; StreamWriter outputfile = null; directory = new System.IO.DirectoryInfo(args.BasePath); filesList = directory.GetFiles(args.Glob); if (filesList.Length <= 0) { return(@"No files found by given input criteria."); } if (args.LogIt == true) { outputfile = new StreamWriter(args.Log, true); } int FilesWorkedOn = 0; foreach (FileInfo file in filesList) { string newxml = null; XmlDocument x = new XmlDocument(); x.Load(file.FullName); newxml = x.OuterXml; if (args.Xslt == true) { XslCompiledTransform myXslTrans = new XslCompiledTransform(); myXslTrans.Load(args.XsltFile); StringWriter stringwriter = new StringWriter(); XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.IndentChars = "\t"; settings.OmitXmlDeclaration = true; XmlWriter myWriter = XmlWriter.Create(stringwriter, settings); myXslTrans.Transform(x, null, myWriter); newxml = stringwriter.ToString(); } if (args.PrettyPrint == true) { newxml = PrettyXml(newxml); } x.LoadXml(newxml); if (args.Overwrite == true) { x.Save(file.FullName); } else { int status = 0; status = FileTool.FileDirectoryOrNothing(args.Output); switch (status) { case (int)FileTool.filesystemObjectStatus.Directory: x.Save(args.Output + @"\" + @file.Name); break; case 0: case (int)FileTool.filesystemObjectStatus.File: x.Save(args.Output); if (filesList.Length > 1 && FilesWorkedOn == 0) { log(args, outputfile, @"Warning: Multiple input files found yet output is a single file."); } break; default: break; } } FilesWorkedOn++; log(args, outputfile, @"Processed Xml " + file.FullName); } if (outputfile != null) { outputfile.Flush(); outputfile.Close(); } return(ErrorMessage); }