({{, (RefLink[FileSize, paclet:ref/FileSize])[file] 
gives the size of a file as a quantity.}})

OpenersNotesSection(Spacer1)Details

(RefLink[FileSize, paclet:ref/FileSize]) returns a (RefLink[Quantity, paclet:ref/Quantity]) object.

(RefLink[FileSize, paclet:ref/FileSize]) uses units of bytes, kilobytes, megabytes, etc. to give a conveniently readable representation of the file size.

The file in (RefLink[FileSize, paclet:ref/FileSize]) can be specified by giving the path to the file as a string or a (RefLink[File, paclet:ref/File]) object.

(RefLink[FileSize, paclet:ref/FileSize]) also works with cloud objects.

OpenersPrimaryExamplesSection(Spacer1)Examples  (6)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

Get the size of a file:

FileSize[FindFile["ExampleData/ocelot.jpg"]]

OpenersExampleSection1(Spacer1)Scope  (2)

Get the file size for a (RefLink[File, paclet:ref/File]) object:

FileSize[FindFile["ExampleData/GSM263810.txt"]]

Find the size of a (RefLink[CloudObject, paclet:ref/CloudObject]):

obj=CloudPut[10!,CloudObject[]]

FileSize[obj]

OpenersExampleSection2(Spacer1)Generalizations & Extensions  (1)

(RefLink[FileSize, paclet:ref/FileSize]) uses SI prefix values for file size, where a megabyte is (10^6) bytes:

size =FileSize[File[FindFile["ExampleData/GSM263810.txt"]]]

UnitConvert[size,"Kilobytes"]

The resulting (RefLink[Quantity, paclet:ref/Quantity]) can be converted to other units using (RefLink[UnitConvert, paclet:ref/UnitConvert]):

UnitConvert[size,"Kibibytes"]

OpenersExampleSection4(Spacer1)Applications  (1)

Use (RefLink[FileSize, paclet:ref/FileSize]) with (RefLink[FileSystemMap, paclet:ref/FileSystemMap]) to inspect the size of various files in a directory:

FileSystemMap[FileSize,$InstallationDirectory<>"/Documentation/English/System/ExampleData",FileNameForms->"*.gz"]

OpenersExampleSection5(Spacer1)Properties & Relations  (1)

(RefLink[FileSize, paclet:ref/FileSize]) gives the same number of bytes as (RefLink[FileByteCount, paclet:ref/FileByteCount]):

FileByteCount[FindFile["ExampleData/ocelot.jpg"]]

FileSize[FindFile["ExampleData/ocelot.jpg"]]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[FileByteCount, paclet:ref/FileByteCount])  ▪  (RefLink[FileDate, paclet:ref/FileDate])  ▪  (RefLink[FileSystemMap, paclet:ref/FileSystemMap])  ▪  (RefLink[ByteCount, paclet:ref/ByteCount])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Memory Measurement & Optimization, paclet:guide/MemoryMeasurementAndOptimization])}, {▪(RefLinkPlain[File Operations, paclet:guide/FileOperations])}, {▪(RefLinkPlain[Files, paclet:guide/Files])}, {▪(RefLinkPlain[Structured Data in the Cloud, paclet:guide/StructuredDataInTheCloud])}, {▪(RefLinkPlain[Managing Content in the Cloud, paclet:guide/ManagingContentInTheCloud])}})}})