public List <MemoryStream> ExtractZipToStream(string ZipFullPath, string SearchPattern, string Password) { List <MemoryStream> aZipStream = new List <MemoryStream>(); ZipFile zf = null; try { FileStream fs = File.OpenRead(ZipFullPath); zf = new ZipFile(fs); if (!string.IsNullOrEmpty(Password)) { zf.Password = Password; // AES encrypted entries are handled automatically } long TotalCount = zf.Count; foreach (ZipEntry Entry in zf) { if (!Entry.IsFile) { continue; // Ignore directories } if (!CLang.Like(Entry.Name, SearchPattern, true)) { continue; } string DirectoryName = Path.GetDirectoryName(Entry.Name); string FileName = Path.GetFileName(Entry.Name); byte[] buffer = new byte[4096]; // 4K is optimum Stream zipStream = zf.GetInputStream(Entry); MemoryStream ms = CFile.GetMemoryStreamFromStream(zipStream); aZipStream.Add(ms); } } finally { if (zf != null) { zf.IsStreamOwner = true; // Makes close also shut the underlying stream zf.Close(); // Ensure we release resources } } return(aZipStream); }
public static IntPtr GetHandleByWindowCaptionAndSizeLike(string Caption, Size Size, int SizeTolerance) { Dictionary <IntPtr, IntPtr> aChildParent = new Dictionary <IntPtr, IntPtr>(); GetHandleList(ref aChildParent, GetDesktopWindow(), true); foreach (KeyValuePair <IntPtr, IntPtr> kv in aChildParent) { CInfoWindow Info = kv.Key.GetWindowInfo(); if (!string.IsNullOrEmpty(Caption) && CLang.Like(Info.Caption, Caption, true) && (Math.Abs(Info.PositionSize.Width - Size.Width) <= SizeTolerance) && (Math.Abs(Info.PositionSize.Height - Size.Height) <= SizeTolerance) ) { return(kv.Key); } } return(IntPtr.Zero); }
public static IntPtr GetHandleByWindowCaptionLike(string WindowCaption) { Dictionary <IntPtr, IntPtr> aChildParent = new Dictionary <IntPtr, IntPtr>(); GetHandleList(ref aChildParent, GetDesktopWindow(), true); foreach (KeyValuePair <IntPtr, IntPtr> kv in aChildParent) { string Caption = GetWindowCaptionByHandle(kv.Key); if (string.IsNullOrEmpty(Caption)) { continue; } //Debug.WriteLine(Caption); if (CLang.Like(Caption.ToString(), WindowCaption, true)) { return(kv.Key); } } return(IntPtr.Zero); }