예제 #1
0
        private static Stream OpenStream(string path)
        {
            if (cache.ContainsKey(path))
            {
                return(cache[path].Clone());
            }

            lock (cache)
            {
                if (cache.ContainsKey(path))
                {
                    return(cache[path].Clone());
                }

                using (FileStream fs = File.OpenRead(path))
                {
                    cache.Add(path, fs.Clone());
                    return(cache[path].Clone());
                }
            }
        }
예제 #2
0
 /// <summary>
 /// Add a entrie in the ZIP archive from file.
 /// </summary>
 /// <param name="entryName"></param>
 /// <param name="filePath"></param>
 /// <returns></returns>
 public void AddEntryFromFile(string entryName, string filePath)
 {
     using (FileStream file = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
         AddEntry(entryName, file.Clone());
 }