public ImageModel(string name, Stream stream, PhotoAlbumModel album) { Name = name; this.filename = album.Path.TrimEnd('/') + "/" + name; this.Album = album; var buffer = Uilt.GetBytes(stream); File.WriteAllBytes(filename, buffer); Md5 = Uilt.GetMd5(buffer); this.Size = buffer.Length; Image = Image.FromStream(stream); this.Width = Image.Width; this.Height = Image.Height; this.CreateTime = DateTime.Now; this.LastAccess = DateTime.Now; }
public ImageModel(string name, string filename, PhotoAlbumModel album) { Name = name; this.filename = filename; this.Album = album; var fi = new FileInfo(this.filename); if (!(_isExists = fi.Exists)) { return; } this.Size = fi.Length; this.Md5 = Uilt.GetMd5(File.ReadAllBytes(filename)); Image = Image.FromFile(filename); this.Width = Image.Width; this.Height = Image.Height; this.CreateTime = fi.CreationTime; this.LastAccess = fi.LastAccessTime; }