1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
#include <stdio.h> // for FILE, fopen, fstat, fileno, fread and fclose
#include <sys\stat.h> // for fstat and the stat struct
void __fastcall TForm1::Button1Click(TObject *Sender)
{
for (int i = 0; i < FileListBox1->Items->Count; i++)
{
if (FileListBox1->Selected[i])
{
if (!FileExists(FileListBox1->Items->Strings[i]))
{
MessageBeep(0);
if (Application->MessageBox(
String("File " + FileListBox1->Items->Strings[i] + "not found").c_str(),
NULL,
MB_OKCANCEL) == IDCANCEL)
break;
else
continue;
}
FILE *F = fopen(AnsiString(FileListBox1->Items->Strings[i]).c_str(),"r");
struct stat statbuf;
fstat(fileno(F), &statbuf);
ListBox1->Items->Add(
FileListBox1->Items->Strings[i] + ": " + IntToStr(int(statbuf.st_size)));
fclose(F);
}
}
} |