Skip to content

FileSizeOf (file size)

ts
function FileSizeOf(path: string): number;

NOTE

This function is available as of Syncplify Server! v7.1.1. If you are running an older version, upgrade to v7.1.1 or later to use it.

Returns the size of the file at path in bytes.

ParameterTypeRequirementExplanation
pathstringrequiredFully qualified path to the file
Return valueExplanation
number (≥ 0)Size of the file in bytes
-1The file does not exist or cannot be stat'd

Example

ts
var size = FileSizeOf('/var/inbox/transfer.bin');
if (size < 0) {
  Log('File not found.');
} else if (size === 0) {
  Log('File is empty, skipping.');
} else {
  Log('File size: ' + size + ' bytes');
}

NOTE

For more detailed information about a file (name, type, modification time, and size together), use StatFileSystemObject. FileSizeOf is a lighter alternative when only the size is needed.