using System.Collections.Generic; using System.IO; namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils { public class DrawPDFHelper { private static string PDF_PATH = @"\\192.168.1.160\plm系统文档\线材选型\图纸\"; private static Dictionary _pdfDataDict = new Dictionary(); public static void CacheAllPdfToMemory() { var path = PDF_PATH; var files = Directory.GetFiles(path, "*.pdf"); foreach (var file in files) { var drawId = Path.GetFileNameWithoutExtension(file); var data = File.ReadAllBytes(file); _pdfDataDict.Add(drawId, data); } } public static MemoryStream GetPDFStream(string drawId) { if (_pdfDataDict.ContainsKey(drawId)) { var data = _pdfDataDict[drawId]; return new MemoryStream(data); } return null; } public static void ClearCache() { _pdfDataDict.Clear(); } } }