/// <summary> /// Load file stream for the file head object. /// </summary> /// <param name="fileHeadObject"></param> /// <returns></returns> public Stream Load(FileHeadObject fileHeadObject) { string fileStoragePath = this.ResolveFileStoragePath(this.applicationContext.ApplicationId, fileHeadObject.Category, fileHeadObject.Id, fileHeadObject.FileExtensionName); if (!File.Exists(fileStoragePath)) throw new FileNotFoundException(); return new FileStream(fileStoragePath, FileMode.Open, FileAccess.Read, FileShare.Read, 16384); }
public Stream Load(FileHeadObject fileHeadObject) { Kit.NotNull(fileHeadObject, "fileHeadObject"); if (!this.fileStreamContainer.ContainsKey(fileHeadObject.Id)) return null; MemoryStream memStream = new MemoryStream(); Stream sourceStream = this.fileStreamContainer[fileHeadObject.Id]; byte[] buffer = new byte[4096]; int byteCount = 1; while (byteCount > 0) { byteCount = sourceStream.Read(buffer, 0, 4096); memStream.Write(buffer, 0, byteCount); } memStream.Position = 0; return memStream; }