程序中循环向ftp服务器上传文件,但是每运行一会(上传几条后)便会提示一个错误
Project UpLoad.exe raised exception class EAccessViolation with message 'Access violation at address 00000000. Read of address 00000000 '. Process stopped. Use Step or Run to continue. 程序调试发现每次报错都是在下面这段代码上: FmyFtp :Tidftp;
FMyFtp.Put(FileLocalPath,(ExtractFileName(FileLocalPath))); FileLocalPath为本地文件绝对路径请教高手!这可能是什么原因造成的?
Project UpLoad.exe raised exception class EAccessViolation with message 'Access violation at address 00000000. Read of address 00000000 '. Process stopped. Use Step or Run to continue. 程序调试发现每次报错都是在下面这段代码上: FmyFtp :Tidftp;
FMyFtp.Put(FileLocalPath,(ExtractFileName(FileLocalPath))); FileLocalPath为本地文件绝对路径请教高手!这可能是什么原因造成的?
function TFtpThread.FtpFileExists(FileName: string):Boolean;
begin
Result := False;
try
if FMyFtp.Size(FileName) = -1 then //没有返回 -1 函数返回 true 文件不存在
begin
Result := True;
end;
except
end;end;
//文件上传函数
function TFtpThread.UpLoadToFtp(FileLocalPath:string):Boolean;
begin
Result := True;
Try
if FtpFileExists(FileLocalPath) then //文件不存在,上传
begin
FMyFtp.Put(FileLocalPath,(ExtractFileName(FileLocalPath)));
end;
except
Result := false;
end;
end;// 上传线程
procedure TFtpThread.Execute;
begin
while not Self.Terminated do
begin
if FMyftp.Connected then
begin
UpLoadToFtp(TmpFile);//tmpFile是从一个list里面循环读取出来的!
end;
end;end;
TmpFile 你传个空值或者非法路径看看什么效果。
tmpFile是从一个list里面循环读取出来的,能保证一直是有效路径吗?