Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to get the size of a file by name. Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
Get the size of a file by name. 15-Aug-04
Category
Files Operation
Language
Delphi All Versions
Views
285
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
Philipp, Steve
Reference URL:
www.HeuristicResearch.com
			1   unit Unit1;
2   
3   interface
4   
5   uses
6     Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
7     Dialogs, StdCtrls;
8   
9   type
10    TForm1 = class(TForm)
11      Button1: TButton;
12      procedure Button1Click(Sender: TObject);
13    private
14      { Private declarations }
15    public
16      { Public declarations }
17    end;
18  
19  var
20    Form1: TForm1;
21  
22  implementation
23  
24  {$R *.dfm}
25  
26  function FileSizeByName(const Fn: string): Int64;
27  //this function returns the size of any given file in bytes
28  
29  var
30    SearchRec: TSearchRec;
31    i: Integer;
32  begin
33    try
34      i:= FindFirst(Fn, faAnyFile, SearchRec);
35      if i = 0 then Result:= SearchRec.Size
36      else Result:= -1;
37    finally
38      FindClose(SearchRec);
39    end;
40  end;
41  
42  procedure TForm1.Button1Click(Sender: TObject);
43  var
44  i:int64;
45  begin
46      i:= FileSizeByName('C:\winnt\notepad.exe');
47     showmessage('The size of the file is: '+intToStr(i)+' bytes');
48  end;
49  
50  end.


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC