/// <summary> /// 写入后就释放资源 /// </summary> /// <param name="table"></param> /// <param name="path"></param> /// <param name="encoding"></param> public static void Write(ObjectTableStorage table, Stream path, Encoding encoding = null) { using (ObjectTableWriter writer = new ObjectTableWriter(path, encoding)) { writer.Write(table); } }
private static void ConvertToOneTable(string outDir, string inputPath) { var fileName = Path.GetFileName(inputPath); var outputPath = Path.Combine(outDir, fileName + ".txt.xls"); var ObsFile = ObsFileUtil.ReadFile(inputPath); var table = ObsFile.BuildObjectTable(true); ObjectTableWriter.Write(table, outputPath); }
public void Complete() { table.Name = "SiteInfo"; var path = Path.Combine(this.OutputDirectory, "SiteInfo.txt.xls"); Utils.FileUtil.CheckOrCreateDirectory(this.OutputDirectory); var span = DateTime.Now - startTime; var m = span.TotalMinutes; var seconds = span.TotalSeconds; int FileCount = InputRawPathes.Length; ObjectTableWriter.Write(table, path); string info = "Completed, the total number is " + FileCount + ". The time consumption is " + m.ToString("0.000") + "m=" + seconds.ToString("0.00") + "s, with an average of " + (seconds / FileCount).ToString("0.000") + "s each file"; log.Info(info); }
/// <summary> /// 写一个表 /// </summary> /// <param name="storage"></param> /// <param name="directory"></param> /// <param name="isOverWrite">是否覆盖</param> public static void WriteTable(ObjectTableStorage storage, string directory, bool isOverWrite = true) { var OutputPath = Path.Combine(directory, storage.Name); if (!OutputPath.EndsWith(TableExtention, StringComparison.CurrentCultureIgnoreCase)) { OutputPath += TableExtention; } if (!isOverWrite && File.Exists(OutputPath)) { storage.log.Warn("忽略了已存在文件 " + OutputPath); return; } var writer = new ObjectTableWriter(OutputPath); writer.Write(storage); writer.CloseStream(); }