代码如下:
Function TMainfrm.UpdateFileXml():Boolean;
var
strTemp, sTemp : String;
iLoop1, iCount: Integer;
src,strFile_S,strFile_D, strDir_D, sDir_D_temp: string; //sDir_D_temp临时存放生成的路径
//strFile_S,strFile_D:string;
S : TSearchRec;
sList: TStringList;
bIsExecOK, bIsDeleted: Boolean;
di: double;
srcList:TStrings;
srclength:Integer;
i:Integer;
sour_path,sour_file: String;
FileRec:TSearchrec;
begin
try
strFile_S:='';
strFile_D:='';
iCount := 0;
Result := False;
strDir_D := '';
strTemp := '========== 文件升级 ==========';
MsgUpdate_Memo.Lines.Add(strTemp);
Css_WriteLog(strTemp);
if GXmlFileList.Count < 1 then
begin
strTemp := '升级包中没有需要进行升级的文件,不需要文件升级';
MsgUpdate_Memo.Lines.Add(strTemp);
Css_WriteLog(strTemp);
end
else
begin
src:= GEXEPATH+'\web\*.*';
sour_path:=ExtractFilePath(src);
sour_file:=ExtractFileName(src);
srcList:=TStringList.Create;
srcList.Clear;
{对文件夹中指定后缀名的文件进行遍历}
if FindFirst(sour_path+sour_file,faAnyfile,FileRec) = 0 then
begin
repeat
if ((FileRec.Attr and faDirectory) = 0) then
begin
srcList.Add(sour_path+FileRec.Name)
end;
until FindNext(FileRec)<>0;
SysUtils.FindClose(FileRec);
end; srclength:=srcList.Count;
for i:=0 to srclength-1 do
begin
strFile_S:=srcList.Strings[i];
strFile_D:=strFile_S.StringReplace(strFile_S,GEXEPATH,GstrU3Path,[rfReplaceAll,rfIgnoreCase]); if FileExists(strFile_S) then
begin
CopyFile(PAnsiChar(strFile_S),PAnsiChar(strFile_D),false);
end;
strFile_S:='';
strFile_D:='';
end;
srcList.Free;
end;
Except on e: Exception do
begin
ShowMessage(e.Message);
MsgUpdate_Memo.Lines.Add('升级结果 :升级失败-' + e.Message);
Css_WriteLog(strTemp);
Result := false;
end;
end;
end;
在红色部分处报错:[Error] uMainunit.pas(714): Record, object or class type required,GEXEPATH,GstrU3Path是2个全局变量,已经定义,麻烦请牛人解答
Function TMainfrm.UpdateFileXml():Boolean;
var
strTemp, sTemp : String;
iLoop1, iCount: Integer;
src,strFile_S,strFile_D, strDir_D, sDir_D_temp: string; //sDir_D_temp临时存放生成的路径
//strFile_S,strFile_D:string;
S : TSearchRec;
sList: TStringList;
bIsExecOK, bIsDeleted: Boolean;
di: double;
srcList:TStrings;
srclength:Integer;
i:Integer;
sour_path,sour_file: String;
FileRec:TSearchrec;
begin
try
strFile_S:='';
strFile_D:='';
iCount := 0;
Result := False;
strDir_D := '';
strTemp := '========== 文件升级 ==========';
MsgUpdate_Memo.Lines.Add(strTemp);
Css_WriteLog(strTemp);
if GXmlFileList.Count < 1 then
begin
strTemp := '升级包中没有需要进行升级的文件,不需要文件升级';
MsgUpdate_Memo.Lines.Add(strTemp);
Css_WriteLog(strTemp);
end
else
begin
src:= GEXEPATH+'\web\*.*';
sour_path:=ExtractFilePath(src);
sour_file:=ExtractFileName(src);
srcList:=TStringList.Create;
srcList.Clear;
{对文件夹中指定后缀名的文件进行遍历}
if FindFirst(sour_path+sour_file,faAnyfile,FileRec) = 0 then
begin
repeat
if ((FileRec.Attr and faDirectory) = 0) then
begin
srcList.Add(sour_path+FileRec.Name)
end;
until FindNext(FileRec)<>0;
SysUtils.FindClose(FileRec);
end; srclength:=srcList.Count;
for i:=0 to srclength-1 do
begin
strFile_S:=srcList.Strings[i];
strFile_D:=strFile_S.StringReplace(strFile_S,GEXEPATH,GstrU3Path,[rfReplaceAll,rfIgnoreCase]); if FileExists(strFile_S) then
begin
CopyFile(PAnsiChar(strFile_S),PAnsiChar(strFile_D),false);
end;
strFile_S:='';
strFile_D:='';
end;
srcList.Free;
end;
Except on e: Exception do
begin
ShowMessage(e.Message);
MsgUpdate_Memo.Lines.Add('升级结果 :升级失败-' + e.Message);
Css_WriteLog(strTemp);
Result := false;
end;
end;
end;
在红色部分处报错:[Error] uMainunit.pas(714): Record, object or class type required,GEXEPATH,GstrU3Path是2个全局变量,已经定义,麻烦请牛人解答
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货