delphi通过url下载文件
2021-05-05 09:27
标签:nload send btn service des contract stream dcl creat procedure TfrmEngineerImport.btnDownloadClick(Sender: TObject); { if DownloadFile(AnsiToUtf8(SourceFile), DestFile) then ServiceDataModule.CloseUniQry(vUniqry); delphi通过url下载文件 标签:nload send btn service des contract stream dcl creat 原文地址:http://www.cnblogs.com/xwgcxk/p/7687892.html
var
vsql, SourceFile, DestFile, filename, filepath: string;
DownLoadFile: TFileStream;
vUniqry: TUniQuery;
begin
vSql := ‘SELECT a.attachment_name,a.attachment_url FROM qo_order t inner join qo_order_schedule os on os.qo_order_id=t.id ‘ +
‘ inner join qo_order_sch_process p on p.qo_order_schedule_id=os.id ‘ +
‘ inner join qo_order_sch_process_atta a on a.qo_order_sch_process_id=p.id ‘ +
‘where t.wc_contract_id=413‘;
ServiceDataModule.GetUniQry(vUniqry);
ServiceDataModule.OpenUniQueryBySQL(vUniqry, vSql);
with vUniqry do
begin
First;
while not Eof do
begin
filepath := fieldbyname(‘attachment_url‘).AsString;
filename := fieldbyname(‘attachment_name‘).AsString;
SourceFile := ‘http://127.0.0.1:8080/‘ + filepath + ‘/‘ + filename;
DestFile := ‘c:\img\‘+filename;
begin
mmoLog.Lines.Add(filename + ‘:Download succesful!‘)
end
else
begin
mmoLog.Lines.Add(SourceFile)
end; }
DownLoadFile := TFileStream.Create(DestFile, fmCreate);
IdHTTP1.Get(AnsiToUtf8(SourceFile), DownLoadFile);
DownLoadFile.Free;
Next;
end;
end;
end;
上一篇:C#中的各种json取值
下一篇:C# 控件拖动