function FormatByteSize(Bytes: Int64): string;
//Converts a numeric value into a string that represents the number expressed as a size value in bytes, kilobytes, megabytes, or gigabytes, depending on the size
var
iSize: array[0..255] of WideChar;
begin
Result := '';
// same formating used in statusbar of Explorer
Result := ShLwApi.StrFormatByteSizeW(Bytes, iSize, Length(iSize) - 1);
end;
uses ShLwApi, hyieutils;
procedure TForm1.Button1Click(Sender: TObject);
var
iOpenDialog: TOpenDialog;
iFilename: string;
iFileSize: integer // bytes
begin
iOpenDialog := TOpenDialog.Create(self);
try
iOpenDialog.Filter := OPEN_MEDIA_FILES_EXTENDED;
if iOpenDialog.Execute then
begin
iFilename := iOpenDialog.Filename;
// get the filesize
iFileSize := IEGetFileSize(iFilename)
Label1.Caption := 'File Size: ' + FormatByteSize(iFileSize);
end;
finally
iOpenDialog.Free;
end;
end;
This would be pointless for multi-selected files, because only the last multi-selected file name would appear in the Label, so I removed OpenDlg.Options := [ofAllowMultiSelect];
William Miller
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html