Convert file size unity (from bytes to Megabytes)

Convert file size unity (from bytes to Megabytes)

Hi everyone,

Is there any way to convert/translate the file size unity (from bytes to Megaybtes, for instance)?

Thanks in advance.
Hi Ricardo,

The file size... where?

The conversion table is the following:

1 KB = 1024 Bytes
1 MB = 1024 KiloBytes
1GB = 1024 MegaBytes
1TB = 1024 GigaBytes get the picture.

So I'd say that, in the expression that is displaying the data in a certain unit, you just convert it to the one you want.

Does this make sense?


Paulo Tavares

I do know those conversion rules.

Maybe, I didn't tell the whole story.

What I wonder is: is there any built-in action, or something,  that does that conversion, or do I have to do it, as we say in Portugal, "à mão"?
I'm using the BynaryDataSize() referenced action to get the size of a specific file and then show it to the user.

The problem is: that action returns the file size in bytes, but I want to show it in MegaBytes. How do I do that? Is there any action that does that for me, or will I have to do it myself?

I hope you did got my point, this time.

Hi Ricardo.

When you say "à mão" you mean dividing by 1024^2  the value returned by BynaryDataSize() ? All you need is an Assign element with some math in it...

Hi João,

Yes, that's what I meant.
From your answer, I now see there's not an action that does that math, and all I need to use is an Assign element.


You can try to build an extension in VisualSudio.

Daniel Maia

Well, yes, but... if you want to encapsulate that logic in an action, you might as well do it in a Service Studio action, and make it a function :)


Paulo Tavares