In this knowledge base article we will show how you can display the file size on the page using transformation.
You can e.g. call
// Get current attachment GUID
Guid attachGuid = CMS.GlobalHelper.ValidationHelper.GetGuid(fileAttachmentGuidId, Guid.Empty);
if (attachGuid != Guid.Empty)
{
// Get the attachment
AttachmentManager am = new AttachmentManager();
AttachmentInfo ai = am.GetAttachmentInfo(attachGuid, CMSContext.CurrentSite.SiteName);
if (ai != null)
{
string attExtension = ai.AttachmentExtension;
return DataHelper.FileSizeFormat(ai.AttachmentSize);
}
}
return string.Empty;