вот, нашла как сделать, может кому пригодится:
| Код | void __fastcall TMainForm::FindFileDataTime() //ищем файла для сортировки по дате { TSearchRec search_rec; AnsiString Dir = edtSrcDir->Text; DynamicArray<TDateTime> FileNames; TDateTime t; int k = 0;
try { Dir = Dir + "\\*.ntar";
int error_code = FindFirst(Dir, faAnyFile, search_rec); if (error_code != 0) { MessageDlg("В выбранном каталоге нет ни одного файла с расширением *.ntar.",mtWarning,TMsgDlgButtons() << mbOK, 0); return; } ++FileNames.Length; k = FileNames.Length - 1; t = FileTimeToDateTime(search_rec.FindData.ftCreationTime); FileNames[k] = t;
while ( 0 == error_code ) { error_code = FindNext(search_rec); if (error_code != 0) { ++FileNames.Length; k = FileNames.Length - 1; t = FileTimeToDateTime(search_rec.FindData.ftCreationTime); FileNames[k] = t; } } } __finally { FindClose(search_rec); } } //------------------------------------------------------------------------ TDateTime __fastcall TMainForm::FileTimeToDateTime(FILETIME ft) { FILETIME mt; SYSTEMTIME st;
FileTimeToLocalFileTime(&ft, &mt); FileTimeToSystemTime(&mt, &st); return SystemTimeToDateTime(st); }
|
|