AutoPlay Media Studio 9

File.GetSize

File.GetSize

This is the first topic This is the last topic  

File.GetSize

This is the first topic This is the last topic  

OverviewExamples

number File.GetSize (

string Filename )

Example 1

file_size = File.GetSize(_TempFolder .. "\\setup.exe");

Gets the size (in bytes) of the file "setup.exe" located in the user's Temp directory and stores it in the variable "file_size."

Note: _TempFolder is a built-in variable that contains the path to the user's system "Temp" folder.

Example 2

-- Searches for a specific file on the user's system.

location = File.Find("C:\\", "target.txt", false, false, nil);

 

if (location ~= nil) then

   -- Check the size of the first file that was found.

   file_size = File.GetSize(location[1]);

 

   if (file_size ~= -1) then

      -- See if the file is 25 bytes. Display a valid or invalid file message to the user.

      if (file_size == 25) then

          Dialog.Message("Success", "The file on your system has been validated.");

      else

          Dialog.Message("Failure", "The file on your system is not valid.");

      end

  else

      Dialog.Message("Failure", "The file on your system could not be validated.");

  end

else

  -- Display a message that the target file was not found.

  Dialog.Message("Notice","The file 'target.txt' was not found.");

end

Searches for a file called "target.txt" in the root of the C:\ drive. If the file is found, its file size is read and compared to the value 25 bytes. Based on the validation results, an appropriate dialog message is displayed.

See also: Related Actions


Learn More: Indigo Rose Software - AutoPlay Media Studio - Buy Now - Contact Us