File_Size(pFileName), Dword
pFileName: The name of the file whose size you want to check. It should be a string with a maximum length of 12 characters, including the file extension (e.g., "MyFile.txt").
Result Dword: The size of the specified file in bytes.
Get the Size of a File
File_Size() is used to get the size of a file, specified by its name, in bytes. This function returns the file size based on the file stored on the SD card.
Example:
File_Size("MyFile.txt")
Notes:
• File Size is returned in bytes.
• File Size Calculation: If the file is large, the size might exceed the typical range of smaller integer types, so Dword (32-bit) is used to handle large file sizes.
Limitation:
• File_Open(), File_Append(), or File_OpenAt(): Ensure that the file is not currently open when using File_Size(). If the file is open, use File_SizeOpen() instead to get the size of the currently open file.
TftSetUp(0) 'Set screen TftResetScreen(BLACK) 'Reset screen TftSetSndFont(0,0) 'Set Font0 While File_Init() <> cErrOK : Wend 'Initialize SD Card TftPrintSndString("Sd Initialization OK",1,0,0,1,GREEN,BLACK,0) 'Confirm Initialize SD Card dTemp = File_Size("dog.bmp") 'Get dog.bmp size dTemp = dTemp / 1024 'Convert to KB TftPrintSndString("dog.bmp=" + Str$(Dec dTemp),1,0,2,1,GREEN,BLACK,0) 'Display file size dTemp = File_Size("Bird.jpg") 'Get Bird.jpg size dTemp = dTemp / 1024 'Convert to KB TftPrintSndString("Bird.jpg=" + Str$(Dec dTemp),1,0,3,1,GREEN,BLACK,0) 'Display file size dTemp = File_Size("Cat.jpg") 'Get Cat.jpg size dTemp = dTemp / 1024 'Convert to KB TftPrintSndString("Cat.jpg=" + Str$(Dec dTemp),1,0,4,1,GREEN,BLACK,0) 'Display file size |
|
Created with the Personal Edition of HelpNDoc: Streamline Your Documentation Process with a Help Authoring Tool