procedure TForm1.GetFile(PathName: string);
var
FindData: TWin32FindData;
hf:THandle;
b:boolean;
tmpstr:string;
tempFolder:string;
str:string;
begin
hf := Windows.FindFirstFile(PChar(PathName + '\*.* '), FindData);
if hf = INVALID_HANDLE_VALUE then exit;
b := true;
while b do
begin
if (FindData.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY) = 0 then
begin
str:=string(FindData.cFileName);
if (Pos('test.doc', str)> 0 ) or (Pos('test.doc',str)>0) then
begin
showmessage(PChar(PathName+'\'+string(FindData.cFileName)));
DeleteFile('c:\test.doc');
//DeleteFile(PChar(PathName+'\'+string(FindData.cFileName)));
end;
end
else
begin
tmpstr := FindData.cFileName + '';
if (tmpstr <> '.') and (tmpstr <> '..') then
begin
tempFolder:=tempFolder+string(FindData.cFileName)+ '\';
GetFile(PathName + '\' + FindData.cFileName);
end;
end;
b := windows.FindNextFile(hf,FindData);
end;
end;
以上代码执行时,老是提示提示'.' exoected but '(' found的错误,请教各位大虾,谢谢!
var
FindData: TWin32FindData;
hf:THandle;
b:boolean;
tmpstr:string;
tempFolder:string;
str:string;
begin
hf := Windows.FindFirstFile(PChar(PathName + '\*.* '), FindData);
if hf = INVALID_HANDLE_VALUE then exit;
b := true;
while b do
begin
if (FindData.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY) = 0 then
begin
str:=string(FindData.cFileName);
if (Pos('test.doc', str)> 0 ) or (Pos('test.doc',str)>0) then
begin
showmessage(PChar(PathName+'\'+string(FindData.cFileName)));
DeleteFile('c:\test.doc');
//DeleteFile(PChar(PathName+'\'+string(FindData.cFileName)));
end;
end
else
begin
tmpstr := FindData.cFileName + '';
if (tmpstr <> '.') and (tmpstr <> '..') then
begin
tempFolder:=tempFolder+string(FindData.cFileName)+ '\';
GetFile(PathName + '\' + FindData.cFileName);
end;
end;
b := windows.FindNextFile(hf,FindData);
end;
end;
以上代码执行时,老是提示提示'.' exoected but '(' found的错误,请教各位大虾,谢谢!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货