使用vs2015判断rvt文件的revit版本
using System; using System.Text; using System.IO; using System.Text.RegularExpressions;
namespace ReadRvt { class Program { static void Main(string[] args) { string ss = GetRevitVision("E:/测试项目/mine/xx.rvt"); Console.WriteLine("REVIT文件版本:"+ ss); Console.ReadKey(); } public static string GetRevitVision(string path) { string revitVision = null; FileStream stream = new FileStream(path, FileMode.Open); int size = 1024 * 1024; byte[] bytes = new byte[size]; while (stream.Read(bytes, 0, size) > 0) { string str = Encoding.Unicode.GetString(bytes); string pattern = @"Autodesk Revit /d{4}"; var match = Regex.Match(str, pattern); if (match.Success) { revitVision = match.Value.Substring(match.Length - 4, 4); break; } } return revitVision; } } }
运行结果
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/20330.html