Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

Install if file size is greater than...


4 replies to this topic

vaqueros

vaqueros
  • Full Members
  • 53 posts

Posted 04 February 2005 - 17:20

I'm writing an install script that has one condition. A specific file needs to be greater than 355KB in order for the setup to continue. I tried using FileCompare but always kept receiving erroneous results. With the code below I always get the "Unable to compare box".

What would be the best way to perform this check?

------------
GetFileInfo ( COMMONFILES ^ "Microsoft Shared" ^ "Proof" ^ "mssp3en.lex" , FILE_SIZE , nvResult , svResult );
NumToStr (svString, nvResult);
SprintfBox ( INFORMATION , "File Information" , "The file size is %s." , svString );
nResult = FileCompare ( svString , "355000", COMPARE_SIZE);
switch (nResult)
case LESS_THAN:
MessageBox ("File smaller will be updated.", INFORMATION ) ;
case GREATER_THAN:
MessageBox ("File bigger will be updated.", INFORMATION ) ;
case EQUALS:
MessageBox ("Same size.", INFORMATION ) ;
case OTHER_FAILURE:
MessageBox ("Something happened.", INFORMATION ) ;
default:
MessageBox ("Unable to compare.", INFORMATION ) ;
endswitch;
------------

Edited by vaqueros, 04 February 2005 - 17:22.


Taco Bell

Taco Bell

    IS6 Expert

  • Moderators
  • 1,281 posts

Posted 04 February 2005 - 17:57

You also get a numeric result in the form of nvResult, so just do a mathematical comparison against (355 * 1024).
user posted image

Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 05 February 2005 - 10:36

FileCompare expects two file names as parameters, not size strings.

vaqueros

vaqueros
  • Full Members
  • 53 posts

Posted 26 April 2005 - 19:33

If FileCompare compares two files then it won't do me any good. Is there a way to compare the size of a specific file to a pre-determined file size? I want to install the program only if a specific file is larger than 355 KB. How can I check for this and implemet it?

Thank you in advance.

Taco Bell

Taco Bell

    IS6 Expert

  • Moderators
  • 1,281 posts

Posted 27 April 2005 - 00:38

Use the function GetFileInfo with an nType parameter value of FILE_SIZE to get the size of the file in bytes.

Then just do a straight numberical comparison to see if that result is greater than (355 * 1024) bytes.

Edited by Taco Bell, 27 April 2005 - 00:38.

user posted image