くだすれDelphi(超初心者用)その18
■ このスレッドは過去ログ倉庫に格納されています
0092デフォルトの名無しさん
NGNGfunction FindNewestFile(const Path: String): TFileName;
function FileNameToDate(const FileName: TFileName): TDate;
var
y, m, d: Integer;
begin
y := StrToInt(Copy(FileName, 1, 4));
m := StrToInt(Copy(FileName, 5, 2));
d := StrToInt(Copy(FileName, 7, 2));
Result := EncodeDate(y, m, d);
end;
var
sr: TSearchRec;
date, latest: TDate;
begin
latest := 0;
Result := EmptyStr;
if FindFirst(Path, faAnyFile, sr) = 0 then
begin
repeat
date := FileNameToDate(sr.Name);
if latest < date then
begin
Result := sr.Name;
latest := date;
end;
until FindNext(sr) <> 0;
FindClose(sr);
end;
end;
こんな感じかな?もっと効率のいい方法があったら教えてくれ。
■ このスレッドは過去ログ倉庫に格納されています