Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get File Size

Status
Not open for further replies.

ug505

Programmer
Jan 2, 2010
52
US
Hello,

I have a open dialog on my program that I want to get the size of the file selected. I know how to set up the dialog, I just can't figure out how to get the file size. I've tried searching around in Delphi Help, and I looked on the FAQ but can't find anythiing. I even tried Google! Can anyone help?
 
GetFileSize is what you want to Google.

I'm waiting for the white paper entitled "Finding Employment in the Era of Occupational Irrelevancy
 
Thanks for that. I found a different way but now I'm having a problem. I want it in Kilobytes, not Bytes. Is there a way to change this code to show it in Kilobytes?

Code:
procedure TForm1.Open1Click(Sender: TObject);
var
f: file of Byte;
begin
if OpenDialog1.Execute then begin
AssignFile(f, OpenDialog1.FileName);
Reset(f);
SpinEdit1.Value:=FileSize(f);
end;
end;
 
Is there a way to change this code to show it in Kilobytes?

Yes. Do the math. There isn't a handy component or procedure call for everything under the sun.

I'm waiting for the white paper entitled "Finding Employment in the Era of Occupational Irrelevancy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top