123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- /* ==============================================================================
- * 功能描述:RevitVisionUtil
- * 创 建 者:Garrett
- * 创建日期:2019/6/28 9:25:34
- * ==============================================================================*/
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Threading.Tasks;
- namespace ExportStart
- {
- /// <summary>
- /// RevitVisionUtil
- /// </summary>
- public class RevitVisionUtil
- {
- /// <summary>
- /// 获取Revit文件的版本
- /// </summary>
- /// <param name="path">文件路径</param>
- /// <returns></returns>
- 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);
- //if (str.Contains("2014"))
- //{
- // revitVision = "2014";
- // File.WriteAllText(@"D:\abc.txt", str);
- // System.Diagnostics.Process.Start("notepad.exe", path);
- // break;
- //}
- string pattern = @"Autodesk Revit \d{4}";
- var match = Regex.Match(str, pattern);
- if (match.Success)
- {
- revitVision = match.Value.Substring(match.Length - 4, 4);
- //File.WriteAllText(@"D:\abc.txt", str);
- break;
- }
- }
- return revitVision;
- }
- }
- }
|