public void BacthVonverse() { long tick = Environment.TickCount; IAnalyser btAnalyser = new CommonAnalyser(); foreach (FileInfo fInfo in _sourFilenameList) { byte[] buffer = null; using (FileStream stream = new FileStream(fInfo.FullName, FileMode.Open)) { buffer = new byte[stream.Length]; stream.Read(buffer, 0, (int)stream.Length); } // 分析 IBNode rootNode = btAnalyser.Analysis(buffer); // 转换 Iterate(btAnalyser.BNodeList); // 生成新的文件名 string newFilename = String.Format("{0}\\{1}", _destFolder, fInfo.Name); // 保存 buffer = rootNode.ToBytes(); using (FileStream stream = new FileStream(newFilename, FileMode.Create)) { stream.Write(buffer, 0, buffer.Length); } } if (_callBackFunc != null) { _callBackFunc(String.Format("转换完毕, 总用时{0} 秒", (Environment.TickCount - tick) / 1000.0)); } }
/// <summary> /// 保存BT文件 /// </summary> /// <param name="filename">文件保存路径</param> public void SaveFile(string filename) { if (_bRootNode == null) { return; } using (FileStream stream = new FileStream(filename, FileMode.Create)) { byte[] buffer = _bRootNode.ToBytes(); stream.Write(buffer, 0, buffer.Length); } }