T
tk0171
Unregistered / Unconfirmed
GUEST, unregistred user!
各位高手:帮我看看下面代码,错在何处:
//——————————————————————————————————
var
SearchRec:tsearchrec;
status:integer;
dir_name:string;
file_path:string;
file_name:string;
begin
//返回选定的文件目录
dir_name:=directoryoutline1.directory+'/';
status:=findfirst(dir_name+'*.doc',faAnyFile,SearchRec);
try
while status=0 do
begin
if (FileExists(dir_name+SearchRec.Name)
or DirectoryExists(dir_name+SearchRec.Name)) and
not((SearchRec.Attr and faDirectory<>0 ) and
((SearchRec.name='.') or (SearchRec.name='..'))) then
begin
//对数据库进行操作
file_path:=extractfiledir(directoryoutline1.directory);
file_name:=extractfilename(searchrec.name);
table1.IndexFieldNames :='Directory;FileName';
begin
if not table1.FindKey ([file_path,file_name]) then
table1.InsertRecord ([file_path,file_name]);
end;
status:=findnext(SearchRec);
end;
finally
sysutils.findclose(SearchRec);
end;
end;
数据库结构
type text;
directory text;
filename text;
data text;
我怀疑是:indexfieldnames使用的问题,是不是对应的两个字段在数据库中要建立萦引?
//——————————————————————————————————
var
SearchRec:tsearchrec;
status:integer;
dir_name:string;
file_path:string;
file_name:string;
begin
//返回选定的文件目录
dir_name:=directoryoutline1.directory+'/';
status:=findfirst(dir_name+'*.doc',faAnyFile,SearchRec);
try
while status=0 do
begin
if (FileExists(dir_name+SearchRec.Name)
or DirectoryExists(dir_name+SearchRec.Name)) and
not((SearchRec.Attr and faDirectory<>0 ) and
((SearchRec.name='.') or (SearchRec.name='..'))) then
begin
//对数据库进行操作
file_path:=extractfiledir(directoryoutline1.directory);
file_name:=extractfilename(searchrec.name);
table1.IndexFieldNames :='Directory;FileName';
begin
if not table1.FindKey ([file_path,file_name]) then
table1.InsertRecord ([file_path,file_name]);
end;
status:=findnext(SearchRec);
end;
finally
sysutils.findclose(SearchRec);
end;
end;
数据库结构
type text;
directory text;
filename text;
data text;
我怀疑是:indexfieldnames使用的问题,是不是对应的两个字段在数据库中要建立萦引?