public MemoryStream GetThumbnailStream(string absolutePath, int width, int height) { var builder = new ImageBuilder(); var stream = builder.BuildThumb(absolutePath, width, height); var fileName = Path.GetFileNameWithoutExtension(absolutePath); var fileExtension = Path.GetExtension(absolutePath); if (!Directory.Exists(_filesPath)) { Directory.CreateDirectory(_filesPath); } var newPath = GetThumbPath(width, height, fileExtension, _filesPath, fileName); if (!File.Exists(newPath)) { using (var file = new FileStream(newPath, FileMode.Create, System.IO.FileAccess.Write)) { stream.Seek(0, 0); stream.CopyTo(file); file.Flush(); } } stream.Seek(0, 0); return stream; }