Getting File Size: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
m (Added category links.)
m (Adding new author and category links.)
Line 1: Line 1:
{|align=right
{{PageAuthor|sunjammer}}
|<small>Author: [[{{ns:2}}:sunjammer|sunjammer]] ([[{{ns:3}}:sunjammer|talk]], [[{{ns:-1}}:Contributions/sunjammer|contrib]])</small>
 
|}
<br style="clear:both;">
== Description ==
== Description ==
This NSIS script was written by [[user:Smile2Me | Smile2Me]] (Hendri Adriaens). It demonstrates how to use NSIS to determine the length of a file without having to use an extension DLL like FileSize. This is the preferred way of finding out the length of a file.
This NSIS script was written by [[user:Smile2Me | Smile2Me]] (Hendri Adriaens). It demonstrates how to use NSIS to determine the length of a file without having to use an extension DLL like FileSize. This is the preferred way of finding out the length of a file.
Line 40: Line 38:
FunctionEnd</highlight-nsis>
FunctionEnd</highlight-nsis>


[[{{ns:14}}:Disk, Path & File Functions]]
[[Category:Disk, Path & File Functions]]

Revision as of 12:25, 24 June 2005

Author: sunjammer (talk, contrib)


Description

This NSIS script was written by Smile2Me (Hendri Adriaens). It demonstrates how to use NSIS to determine the length of a file without having to use an extension DLL like FileSize. This is the preferred way of finding out the length of a file.

The Script

OutFile FileSizeNew.exe
Name FileSizeNew
 
; FileSizeNew
;
; Script to find the size of a file.
; Much more efficient than the
; ExtensionDLL FileSize :-)
;
; by Hendri Adriaens
;    HendriAdriaens@hotmail.com
 
Section 
 
  Push "$EXEDIR\FileSizeNew.nsi"
  Call FileSizeNew
  Pop $0
  MessageBox MB_OK "File size: $0 bytes."
 
SectionEnd 
 
Function FileSizeNew 
 
  Exch $0
  Push $1
  FileOpen $1 $0 "r"
  FileSeek $1 0 END $0
  FileClose $1
  Pop $1
  Exch $0
 
FunctionEnd