How to get the size of a file in a transformation?

Kentico Support asked on July 1, 2013 15:06

How to get the size of a file in a transformation?

Correct Answer

Kentico Support answered on July 1, 2013 15:06

If you want to get a file size of the CMS.File document type, you need to implement a transformation function with one parameter (FileAttachment) and return AttachmentSize property instead:

AttachmentInfo ai = AttachmentInfoProvider.GetAttachmentInfo(ValidationHelper.GetGuid(<FileAttachment>, Guid.Empty), CMSContext.CurrentSiteName);
return ai.AttachmentSize.ToString();
0 votesVote for this answer Unmark Correct answer

   Please, sign in to be able to submit a new answer.