TrFile_DiskInfo (function reference)

By January 1, 2021January 26th, 2021Online Help, Troi File Plug-in
Troi File Plug-in for FileMaker Pro

TrFile_DiskInfo

Retrieves information about a specified disk, like the number of files.

SyntaxFunction badge

TrFile_DiskInfo ( switches ; diskname )

Parameters

switches this determines which information is returned
diskname the name of the disk

Switches

Switches are different for each platform. For all platforms the switch can be one of this:

-GetIsNetworkDisk returns 1 if it is a remote network disk or 0 if not.
-GetFreeMegs get the number of free Mega bytes (Mb) on this disk
-GetTotalMegs get the size of this disk in Mega bytes (Mb)

Switches are different for each platform. For macOS the switch can be one of this:

-GetFileCount get the number of files on this disk
-GetFolderCount get the number of folders on this disk

For Windows the switch can be one of this:

-GetVolumeLabel get the label of the disk, for example "C Disk"
-GetVolumeSerialNumber get the serialnumber of the disk, for example "123234"
-GetUniversalName get the Universal Name of a shared network drive
-GetDriveLetter get the drive letter from a Universal Name of a shared network drive

Returned Result

Data type returned

Text

Result

The returned result is a number or an error code. An error always starts with 2 dollars, followed by the error code. You should always check for errors. Returned error codes can be:

$$-35 nsvErr No such volume, disk not found
$$-50 paramErr Parameter error, check if the supplied parameters are correct
$$2250 Not connected to a network

Other errors may be returned.

Originated in

Troi File Plug-in 2.1

Compatibility

FileMaker Pro 16 to 19

Considerations

The switches -GetUniversalName and -GetDriveLetter are available in the 2.5×2 version or later on Windows only.

Example

Set Field [ result ; TrFile_DiskInfo ( "-GetTotalMegs" ; "C:" ) ]
Set Field [ result ; TrFile_DiskInfo ( "-GetFreeMegs" ; "Server1" ) ]
Set Field [ result ; TrFile_DiskInfo ( "-GetFileCount" ; "Mac HD" ) ]

These steps will return the total and the free number of Mb of the disk. The last step will return the number of files on the disk “Mac HD”. Note this is available on macOS only.

Set Field [ result ; TrFile_DiskInfo ( "-GetVolumeSerialNumber" ; "C:" ) ]

This will return the serialnumber of the hard disk C. Note this is available on Windows only.

Example 2

We assume that in your FileMaker file the following fields are defined:

  gFolderCount			Global, number
  gDiskName			Global, text

gDiskName should contain the name of a hard disk. In a script add the following script step:

Set Field [ gFolderCount ; TrFile_DiskInfo ( "-GetFolderCount" ; gDiskName ) ]

This will return the number of folders on the disk.

Example 3

This example describes how to work with UNC’s, which are only available on Windows. We assume that in your FileMaker file the following fields are defined:

  gFolderCount			Global, number
  gDiskName			Global, text
  gUNC_Name			Global, text

gDiskName should contain the name of a remote hard disk, for example “Z:”. In a script add the following script steps:

Set Field [ gUNC_Name ; TrFile_DiskInfo ( "-GetUniversalName" ; gDiskName ) ]

This will return the UNC, for example “\\Server3\\SharedDocs”. If you want to do the reverse add this step:

Set Field [ gDiskName ; TrFile_DiskInfo ( "-GetDriveLetter" ; gUNC_Name ) ]

To mount a shared hard disk with a UNC see the function TrFile_MountDisk.

Used in example file

DiskInfo.fmp12

Related functionsFunction badge

TrFile_ListDisks
TrFile_MountDisk

Related topics

Troi File Plug-in online help (overview)


Online Help Page for Troi File Plug-in for 16 to 19 –> TrFile_DiskInfo (filep4215) 2021-0125 21:33:49