prodownfiles.dpr
来自「用Delphi写的console程序,用于下载网络上的各种文件,供新手学习CON」· DPR 代码 · 共 67 行
DPR
67 行
//-------------------------------------------------------------------------
// 程序名: 文件下载
// 作 用: 从指定的URL(ini文件中指定)中下载文件
// modify: xiegang 20080119
//-------------------------------------------------------------------------
program ProDownFiles;
{$APPTYPE CONSOLE}
uses
ExceptionLog,
SysUtils,
IniFiles,
StdCtrls,
IdBaseComponent,
IdComponent,
IdTCPConnection,
IdTCPClient,
IdHTTP,
Classes,
Forms,
UntPublic in 'UntPublic.pas';
var
Myini:TIniFile;
Filename : string;
Fpath : string;
Furl : string;
SectionName:string;
idHTTP1: TIdHTTP;
vFileStream:TFileStream;
SectionList :TStrings;
SectionId: Integer;
begin
{ TODO -oUser -cConsole Main : Insert code here }
//ShowMessage(ExtractFilePath(Application.Exename));
Myini := TIniFile.Create(ExtractFilePath(Application.Exename)+cfgName);
SectionList := TStringList.Create;
try
Fpath := Myini.ReadString('system','Path','');
Myini.ReadSection('Url',SectionList);
for SectionId := 0 to SectionList.Count-1 do
begin
SectionName := SectionList.Strings[SectionId];
Furl := Myini.ReadString('Url',SectionName,'');
//Filename := Fpath+FormatDateTime('YYYYMMDD',Date)+'.xls';
Filename := Fpath+FormatDateTime('YYYYMMDD',Date)+'\';
if not DirectoryExists(Filename) then
CreateDir(Filename);
Filename := Filename + SectionName;
vFileStream:=TFileStream.Create(Filename,fmCreate);
idHTTP1 := TIdHTTP.Create(nil);
try // 本地存放路径。SavePath+i_SaveToFileName
IdHTTP1.Get(Furl,vFileStream);
finally
vFileStream.Free;
idHTTP1.Free;
end; //try..finally
end; //end for
finally
FreeAndNil(Myini);
end; // end try
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?