请高手将下面的一段Delphi代码(下载整个网站的图片)转换成C#代码
请高手将下面的一段Delphi代码(下载整个网站的图片)转换成C#代码,Delphi代码如下:unit GetMM;
inte易做图ce
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdHTTP;
const
Url='http://www.sergeaura.net/TGP/'; //下载图片的网站地址
OffI=192; //目录个数
OffJ=16; //每个目录下的最大图片数
girlPic='C:\girlPic\'; //保存在本地的路径
//线程类
type
TGetMM = class(TThread)
protected
FMMUrl:string;
FDestPath:string;
FSubJ:string;
procedure Execute;override;
public
constructor Create(MMUrl,DestPath,SubJ:string);
end;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Memo1: TMemo;
IdHTTP1: TIdHTTP;
CheckBox1: TCheckBox;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
RGetMM:TThread;
procedure GetMMThread(MMUrl,DestPath,SubJ:string);
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
//下载过程
procedure TForm1.Button1Click(Sender: TObject);
var
i,j:integer;
SubI,SubJ,CurUrl,DestPath:string;
strm:TMemoryStream;
begin
memo1.Lines.Clear;
//建立目录
if not DirectoryExists(girlPic) then
MkDir(girlPic);
try
strm :=TMemoryStream.Create;
for I:=1 to OffI do
begin
for j:=1 to OffJ do
begin
if (i<10) then
SubI:='00'+IntToStr(i)
else if (i>9) and (i<100) then
SubI:='0'+inttostr(i)
else SubI:=inttostr(i);
if (j>9) then
SubJ:=inttostr(j)
else SubJ:='0'+inttostr(j);
CurUrl:=Url+SubI+'/images/';
DestPath:=girlPic+SubI+'\';
if not DirectoryExists(DestPath) then
ForceDirectories(DestPath);
//使用线程,速度能提高N倍以上
if CheckBox1.Checked then
begin
GetMMThread(CurUrl,DestPath,SubJ);
sleep(500);
end else
//不使用线程
begin
try
strm.Clear;
IdHTTP1.Get(CurUrl+SubJ+'.jpg',strm);
strm.SaveToFile(DestPath+SubJ+'.jpg');
Memo1.Lines.Add(CurUrl+' Download OK !');
strm.Clear;
IdHTTP1.Get(CurUrl+'tn_'+SubJ+'.jpg',strm);
strm.SaveToFile(DestPath+'tn_'+SubJ+'.jpg');
Memo1.Lines.Add(CurUrl+' Download OK !');
except
Memo1.Lines.Add(CurUrl+' Download Error !');
end;
end;
end;
end;
Memo1.Lines.Add('All OK!');
finally
strm.Free;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Close;
end;
{ TGetMM }
constructor TGetMM.Create(MMUrl,DestPath,SubJ: string);
begin
FMMUrl :=MMUrl;
FDestPath :=DestPath;
FSubJ :=SubJ;
inherited Create(False);
end;
procedure TGetMM.Execute;
var
strm:TMemoryStream;
IdGetMM: TIdHTTP;
DestFile:string;
begin
try
strm :=TMemoryStream.Create;
IdGetMM :=TIdHTTP.Create(nil);
try
DestFile :=FDestPath+FSubJ+'.jpg';
if Not FileExists(DestFile) then
begin
strm.Clear;
IdGetMM.Get(FMMUrl+FSubJ+'.jpg',strm);
strm.SaveToFile(DestFile);
end;
DestFile :=FDestPath+'tn_'+FSubJ+'.jpg';
if not FileExists(DestFile) then
begin
strm.Clear;
IdGetMM.Get(FMMUrl+'tn_'+FSubJ+'.jpg',strm);
strm.SaveToFile(DestFile);
end;
except
end;
finally
strm.Free;
IdGetMM.Free;
end;
end;
procedure TForm1.GetMMThread(MMUrl, DestPath, SubJ: string);
begin
RGetMM :=TGetMM.Create(MMUrl,DestPath,SubJ);
end;
end. --------------------编程问答-------------------- 这有何难? --------------------编程问答-------------------- 这有何难?
不好意思,没有学习过“Delphi”,有劳你了! --------------------编程问答-------------------- 自己顶一下 哪位大大帮帮忙呀 万分感谢! --------------------编程问答-------------------- 才20分,翻译程序哪有这么廉价 --------------------编程问答-------------------- 分确实太少了...再加之上班比较忙, --------------------编程问答-------------------- 就是啊,自己玩去吧 --------------------编程问答-------------------- 可悲 一个个分奴!
不搞也就算了 何必这么多言!
--------------------编程问答-------------------- 看你什么态度! --------------------编程问答-------------------- 不可能简简单单就转换的了的。Delphi的代码又不会跟C#的代码一一对应的。而且你里面还用到了TIdHTTP控件。最多用C#实现类似的功能罢了!
补充:.NET技术 , C#