internal static byte[] OpenInclude(GetIncludeEventArgs ea, ExcelFile Workbook) { string iPath = Workbook.ActiveFileName; try { if (iPath.Length > 0) { iPath = Path.GetDirectoryName(iPath) + Path.DirectorySeparatorChar; } } catch (ArgumentException) { iPath = String.Empty; } if (Path.IsPathRooted(ea.FileName)) { iPath = String.Empty; } ea.FileName = iPath + ea.FileName; using (FileStream f = new FileStream(ea.FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) //FileShare.ReadWrite is the way we have to open a file even if it is being used by excel. { byte[] Result = new byte[f.Length]; Sh.Read(f, Result, 0, Result.Length); return(Result); } }
private static byte[] OpenFile(string Path) { using (FileStream fs = new FileStream(Path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) //FileShare.ReadWrite is the way we have to open a file even if it is being used by excel.)) { byte[] b = new byte[fs.Length]; Sh.Read(fs, b, 0, (int)fs.Length); return(b); } }
private void LoadFont(string path) { byte[] b = null; using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) //FileShare.ReadWrite is the way we have to open a file even if it is being used by excel.)) { b = new byte[fs.Length]; Sh.Read(fs, b, 0, (int)fs.Length); } LoadFont(path, b); }
private static byte[] DecodeImage(byte[] Img, int w, int h, int ScanLine) { using (TCompressor Cmp = new TCompressor()) { if (w <= 0) { return(new byte[2]); } byte[] Result = new byte[h * ScanLine]; using (MemoryStream InflatedStream = new MemoryStream()) { unchecked { Cmp.Inflate(Img, 0, InflatedStream); InflatedStream.Position = 0; Sh.Read(InflatedStream, Result, 0, h * ScanLine); return(UnFilter(Result, ScanLine, h)); } } } }
private void ShRead(Stream aDataStream, byte[] Data, int IniOfs, int Count) { Sh.Read(aDataStream, Data, IniOfs, Count); DataStreamPosition += Count; }
internal static void ReadtRNS(UInt32 Len, Stream PngImageData, TPdfPngData OutData) { OutData.tRNS = new byte[Len]; Sh.Read(PngImageData, OutData.tRNS, 0, (int)Len); }