# FileSize

The **FileSize** object is provided to make it easier to deal with variables representing file sizes. It's very common these days for files to be larger than 4GB but unfortunately ActiveX scripting does not have proper support for the 64-bit integers needed to represent such large numbers. Therefore, any time a file size or number representing a number of bytes is returned by the Opus scripting objects, it is as a **FileSize** object. For example, the [**Item**](item)**.size** property returns a **FileSize** representing the size of a particular file or folder.

You can create a new **FileSize** object using the [**FSUtil**](fsutil)**.NewFileSize** method. A FileSize object normally represents an _unsigned_ 64 bit integer but if you specify the _"s"_ flag on creation, it will store a _signed_ integer instead.

| Property Name      | Return Type | Description                                                                                                                                                                                            |
| ------------------ | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| _\<default value>_ | _string_    | Returns the number of bytes represented by this **FileSize** object as a _string_.                                                                                                                     |
| cy                 | _currency_  | Returns the number of bytes as a _currency_ value. This is a 64 bit data type but it is stored as a fractional value, so you must multiply the returned value by 10000 to obtain the actual byte size. |
| fmt                | _string_    | Returns the number of bytes as an automatically formatted string (e.g. if the **FileSize** value is 1024, the string _1 KB_ would be returned).                                                        |
| high               | _decimal_   | Returns the highest (most significant) 32 bits of the file size. Not all scripting languages support this data type (e.g. VBScript does not).                                                          |
| highhex            | _string_    | Returns the highest 32 bits of the file size as a hexadecimal string.                                                                                                                                  |
| low                | _decimal_   | Returns the lowest (least significant) 32 bits of the file size.                                                                                                                                       |
| lowhex             | _string_    | Returns the lowest 32 bits of the file size as a hexadecimal string.                                                                                                                                   |
| val                | _decimal_   | Returns the number of bytes as a decimal value. This is a 64 bit data type but not all scripting languages support it (e.g. VBScript does not).                                                        |
| valhex             | _string_    | Returns the number of bytes as a hexadecimal string.                                                                                                                                                   |

| Method Name | **Arguments** | Return Type               | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| ----------- | ------------- | ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Add         | _variant_     | _none_                    | <p>Adds the supplied value to the value of this <strong>FileSize</strong> object. You can pass a <em>string</em>, <em>int</em> or <em>currency</em> type, or another <strong>FileSize</strong> object.<br>Some <strong>FileSize</strong> objects are read-only and will error if you try to modify them. This includes ones returned by <a href="item"><strong>Item</strong></a><strong>.size</strong>. Use the <strong>Clone</strong> method to create a modifiable copy.</p>                                                                                                                                                                                                                                                     |
| Clone       | _none_        | \*object:\***FileSize**   | Clones this **FileSize** object and returns a new one set to the same value.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| Compare     | _variant_     | _int_                     | Compares the supplied value with the value of this **FileSize** object. The return value will be **0** (equal), **1** (greater) or **-1** (less).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| Div         | _variant_     | _none_                    | <p>Divides the value of this <strong>FileSize</strong> object with the supplied value. You can pass a <em>string</em>, <em>int</em> or <em>currency</em> type, or another <strong>FileSize</strong> object.<br>Some <strong>FileSize</strong> objects are read-only and will error if you try to modify them. This includes ones returned by <a href="item"><strong>Item</strong></a><strong>.size</strong>. Use the <strong>Clone</strong> method to create a modifiable copy.</p>                                                                                                                                                                                                                                                |
| Mult        | _variant_     | _none_                    | <p>Multiplies the value of this <strong>FileSize</strong> object with the supplied value. You can pass a <em>string</em>, <em>int</em> or <em>currency</em> type, or another <strong>FileSize</strong> object.<br>Some <strong>FileSize</strong> objects are read-only and will error if you try to modify them. This includes ones returned by <a href="item"><strong>Item</strong></a><strong>.size</strong>. Use the <strong>Clone</strong> method to create a modifiable copy.</p>                                                                                                                                                                                                                                             |
| Set         | _variant_     | _none_                    | <p>Sets the <strong>FileSize</strong> to the supplied value. You can pass a <em>string</em>, <em>int</em>,// decimal *or *currency// type, or another <strong>FileSize</strong> object. You can also pass a **<a href="blob">Blob</a>**consisting of exactly 1, 2, 4 or 8 bytes, in which case the data contained in the **<a href="blob">Blob</a>**will be used to form the number. You can use a hexadecimal string by pre-pending <strong>$</strong> or <strong>0x</strong>.<br>If the <strong>FileSize</strong> object is read-only, it will error if you try to modify it. Use <strong>Clone</strong> or <a href="fsutil"><strong>FSUtil</strong></a><strong>.NewFileSize</strong> to create a new object you can modify.</p> |
| Sub         | _variant_     | _none_                    | <p>Subtracts the supplied value from the value of this <strong>FileSize</strong> object. You can pass a <em>string</em>, <em>int</em> or <em>currency</em> type, or another <strong>FileSize</strong> object. Note that the <strong>FileSize</strong> object is <em>unsigned</em> and so the value cannot go below zero.<br>Some <strong>FileSize</strong> objects are read-only and will error if you try to modify them. This includes ones returned by <a href="item"><strong>Item</strong></a><strong>.size</strong>. Use the <strong>Clone</strong> method to create a modifiable copy.</p>                                                                                                                                   |
| ToBlob      | _int_         | _object:_[**Blob**](blob) | Returns a \*\*[Blob](blob)\*\*containing the bytes that make up the current value. By default 8 bytes will be copied to the [**Blob**](blob)(the full 64 bit number) but you can pass an alternative number of bytes (1, 2 or 4) as a parameter to truncate the value.                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
