public ImageInfo(string relativePath) { _fs = FileSystemProviderManager.Current.GetFileSystemProvider <MediaFileSystem>(); try { RelativePath = relativePath; //This get's the IFileSystem's path based on the URL (i.e. /media/blah/blah.jpg ) Path = _fs.GetRelativePath(relativePath); using (var stream = _fs.OpenFile(Path)) using (image = Image.FromStream(stream)) { var fileName = _fs.GetFileName(Path); Name = fileName.Substring(0, fileName.LastIndexOf('.')); DateStamp = _fs.GetLastModified(Path).Date; Width = image.Width; Height = image.Height; Aspect = (float)Width / Height; } } catch (Exception) { Width = 0; Height = 0; Aspect = 0; } }
private void Initialize() { _fileName = _fs.GetFileName(_path); _length = _fs.GetSize(_path); _extension = _fs.GetExtension(_path) != null ? _fs.GetExtension(_path).Substring(1).ToLowerInvariant() : ""; _url = _fs.GetUrl(_path); }