선택한 폴더 안의 폴더 갯수와 그 특정 폴더의 파일 갯수를 구해서 매번 Oracle DB에 갱신을 해줄려고 하는데 계속 한 곳의 폴더에서만 갱신이 되는군요. 부탁좀 드리겠습니다. 그리고 그에 대해서 설명도 해주셨으면 좋겠구요.
procedure Tfrm_Main.CountStringGrid_File(Path: String);
var
sr: TSearchRec;
FileAttrs: Integer;
svSearch: TSearchRec;
sCountSQL: String;
iDept_first: Integer;
iDept_second: Integer;
iDept_third: Integer;
iDept_for: Integer;
SavePath: String;
Loop: Integer;
begin
iDept_first:= 0;
Loop:=0;
iDept_second:= 0;
iDept_third:= 0;
FileAttrs := 0 + faAnyFile;
AdoCon.Open('MFGOVTEST','MFGOVTEST');
ShowMessage('연결성공');
if FindFirst(Path + FileFilter, FileAttrs, sr) = 0 then
ShowMessage(Path);
begin
repeat
inc(iDept_first);
if (sr.name <> '.') and ( sr.Name <> '..') then
begin
if(sr.Attr and faDirectory ) = faDirectory then
begin
sCountSQL:= '';
sCountSQL:=sCountSQL +'insert into countpage_tbl values(';
sCountSQL:=sCountSQL +''''+inttostr(iDept_first) + ' '',''' + inttostr(iDept_second);
sCountSQL:=sCountSQL +''','''+inttostr(0)+ ' '','''+inttostr(0)+' '','' '+ Path + ' '',';
sCountSQL:=sCountSQL +''' ' +sr.Name + ' '',''' + 'D' + ' '',';
sCountSQL:=sCountSQL +inttostr(0)+')';
AdoQuery.SQL.Add(sCountSQL);
AdoQuery.ExecSQL;
AdoQuery.SQL.Clear;
AdoQuery.Close;
SavePath:=Path;
Path:=Path+sr.Name+'\';
svSearch:=sr;
FindFirst(Path+FileFilter,FileAttrs,sr);
repeat
if(sr.Name <> '.') and ( sr.Name <> '..') then
begin
if(sr.Attr and faDirectory ) = faDirectory then begin
inc(iDept_third);
sCountSQL:= '';
sCountSQL:=sCountSQL +'insert into countpage_tbl values(';
sCountSQL:=sCountSQL +''''+inttostr(iDept_first) + ' '',''' + inttostr(iDept_second);
sCountSQL:=sCountSQL +''','''+inttostr(iDept_third)+ ' '',''' +inttostr(0)+' '','' ' + Path + ' '',';
sCountSQL:=sCountSQL +''' ' +sr.Name + ' '',''' + 'D' + ' '',';
sCountSQL:=sCountSQL +inttostr(0)+')';
AdoQuery.SQL.Add(sCountSQL);
AdoQuery.ExecSQL;
AdoQuery.SQL.Clear;
AdoQuery.Close;
end else
inc(iDept_for);
inc(Loop);
sCountSQL:= '';
sCountSQL:=sCountSQL +'insert into countpage_tbl values(';
sCountSQL:=sCountSQL +''''+inttostr(iDept_first) + ' '',''' + inttostr(iDept_second);
sCountSQL:=sCountSQL +''','''+inttostr(iDept_third)+ ' '',''' + inttostr(iDept_for)+ ' '','' '+Path + ' '',';
sCountSQL:=sCountSQL +''' ' +sr.Name + ' '',''' + 'F' + ' '',';
sCountSQL:=sCountSQL +inttostr(0)+')';
AdoQuery.SQL.Add(sCountSQL);
AdoQuery.ExecSQL;
AdoQuery.SQL.Clear;
AdoQuery.Close;
end;
until(FindNext(sr) <> 0);
FindClose(sr);
Path:=SavePath;
ShowMessage(sr.Name);
FindFirst(Path+FileFilter,FileAttrs,sr);
FindNext(sr);
end else
end;
until(FindNext(sr)<>0);
FindClose(sr);
end;
end;
|