L
lym830116
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure Tlym.Execute;
var
MyStream:TMemoryStream;
stream:TFilestream;
name:string;
begin
with Form1do
begin
if edit1.Text='' then
messagebox(handle,'请输入要下载的文件路径!','提示!',MB_OK)
else
begin
//IdAntiFreeze1.OnlyWhenIdle:=False;
//MyStream:=TMemoryStream.Create;
try
if savedialog1.Execute then
begin
try
//showmessage(savedialog1.FileName);
name:=savedialog1.FileName;---------这个地方出错,导致一点反映都没有,想停止程序都比较困难
stream:=Tfilestream.Create(name,fmcreate);
ProgressBar1.Position:=0;
button1.Enabled:=false;
edit1.Enabled:=false;
IdHTTP1.Get(edit1.Text,stream);
//MyStream.SaveToFile(name);
// MyStream.Free;
stream.Free;
messagebox(handle,'下载成功!','提示!',MB_OK);
button1.Enabled:=true;
edit1.Enabled:=true;
except
messagebox(handle,'请确认文件路径输入正确!','提示!',MB_OK);
end;
end;
except
messagebox(handle,'网络连接出错!请确认网络连接正常!','提示!',MB_OK);
MyStream.Free;
Exit;
end;
end;
end;
end;
不明白为什么会出错,如果不用多线程是可以的
var
MyStream:TMemoryStream;
stream:TFilestream;
name:string;
begin
with Form1do
begin
if edit1.Text='' then
messagebox(handle,'请输入要下载的文件路径!','提示!',MB_OK)
else
begin
//IdAntiFreeze1.OnlyWhenIdle:=False;
//MyStream:=TMemoryStream.Create;
try
if savedialog1.Execute then
begin
try
//showmessage(savedialog1.FileName);
name:=savedialog1.FileName;---------这个地方出错,导致一点反映都没有,想停止程序都比较困难
stream:=Tfilestream.Create(name,fmcreate);
ProgressBar1.Position:=0;
button1.Enabled:=false;
edit1.Enabled:=false;
IdHTTP1.Get(edit1.Text,stream);
//MyStream.SaveToFile(name);
// MyStream.Free;
stream.Free;
messagebox(handle,'下载成功!','提示!',MB_OK);
button1.Enabled:=true;
edit1.Enabled:=true;
except
messagebox(handle,'请确认文件路径输入正确!','提示!',MB_OK);
end;
end;
except
messagebox(handle,'网络连接出错!请确认网络连接正常!','提示!',MB_OK);
MyStream.Free;
Exit;
end;
end;
end;
end;
不明白为什么会出错,如果不用多线程是可以的