@helper RenderMediaResult(SearchViewModel model, IPublishedContent result) { var bytes = Convert.ToInt64(@result.GetPropertyValue<string>("umbracoBytes")); var x = ((Math.Round(Convert.ToDecimal(@bytes) / 1048576, 1)).ToString() + "MB"); var y = ((Math.Round(Convert.ToDecimal(@bytes) / 1024, 1)).ToString() + "KB"); var z = (bytes >= 1048576)? x:y;
Display Media items with Date, File size, and Extension
I'm trying to displaying the Media items, to include the date, file size, and extension.
However, I need a variable for the file size, so it display as either "KB" or "MB" etc.
This is my current code, which just displays the umbracoBytes as it's numerical value:
I'd really appreciate some assistance with formatting the "umbracoBytes"
Cheers, JV
Hi JV,
Maybe you could do someting like this.
I foud the inspiration for the code here: http://our.umbraco.org/forum/developers/razor/48326-Converting-to-Int64-Failed
Hope this can help you.
/Dennis
is working on a reply...