T
tasuodi
Unregistered / Unconfirmed
GUEST, unregistred user!
下面是我的ftp上传和下载程序源码,目前只能上传和下载文件,我要完成文件夹的上传和下载。我正在做毕设,但我不懂delphi,所以问的问题比较菜,希望高手们不要计较帮帮我!!!
procedure TFMain.UploadExecute(Sender: TObject);
var
FileName : String;
Item : TListItem;
QueueItem : TListItem;
begin
if not FTPClient.Connected Then Exit;
if LocalFileList.Selected = nil then Exit;
Item := LocalFileList.Selected;
QueueList.Clear;
while Item <> nil do
begin
QueueItem := QueueList.Items.Add;
QueueItem.Caption := Item.Caption;
QueueItem.SubItems.Add(LocaLPath);
QueueItem.SubItems.Add(Item.SubItems[1]);
QueueItem.SubItems.Add('->');
QueueItem.SubItems.Add('');
QueueItem.SubItems.Add(ComboHistory.Text);
Item:=LocalFileList.GetNextItem(Item,sdAll, [isSelected]);
end;
QueueList.Refresh;
LocalFileList.Enabled:=false;
DriveComboBox1.Enabled:=false;
RemoteFileList.Enabled:=False;
ComboHistory.Enabled:=false;
RemoteUpDir.Enabled:=false;
IsTransParent:=True;
try
while QueueList.Items.Count > 0 do
begin
FileName:=QueueList.Items[0].Caption;
QueueList.Items[0].SubItems[3]:='正在上传';
QueueList.Refresh;
FTPClient.Put(LocalPath+'/'+FileName, FileName);
RemoteChangeDirExecute(Sender);
QueueList.items[0].Delete;
QueueList.Refresh;;
end;
LocalFileList.Enabled:=True;
DriveComboBox1.Enabled:=True;
RemoteFileList.Enabled:=True;
ComboHistory.Enabled:=True;
RemoteUpDir.Enabled:=True;
IsTransParent:=False;
except
QueueList.Items[0].SubItems[3]:='错误';
ShowMessage('上传文件错误!');
LocalFileList.Enabled:=True;
DriveComboBox1.Enabled:=True;
RemoteFileList.Enabled:=True;
ComboHistory.Enabled:=True;
RemoteUpDir.Enabled:=True;
IsTransParent:=False;
end;
end;
procedure TFMain.UploadExecute(Sender: TObject);
var
FileName : String;
Item : TListItem;
QueueItem : TListItem;
begin
if not FTPClient.Connected Then Exit;
if LocalFileList.Selected = nil then Exit;
Item := LocalFileList.Selected;
QueueList.Clear;
while Item <> nil do
begin
QueueItem := QueueList.Items.Add;
QueueItem.Caption := Item.Caption;
QueueItem.SubItems.Add(LocaLPath);
QueueItem.SubItems.Add(Item.SubItems[1]);
QueueItem.SubItems.Add('->');
QueueItem.SubItems.Add('');
QueueItem.SubItems.Add(ComboHistory.Text);
Item:=LocalFileList.GetNextItem(Item,sdAll, [isSelected]);
end;
QueueList.Refresh;
LocalFileList.Enabled:=false;
DriveComboBox1.Enabled:=false;
RemoteFileList.Enabled:=False;
ComboHistory.Enabled:=false;
RemoteUpDir.Enabled:=false;
IsTransParent:=True;
try
while QueueList.Items.Count > 0 do
begin
FileName:=QueueList.Items[0].Caption;
QueueList.Items[0].SubItems[3]:='正在上传';
QueueList.Refresh;
FTPClient.Put(LocalPath+'/'+FileName, FileName);
RemoteChangeDirExecute(Sender);
QueueList.items[0].Delete;
QueueList.Refresh;;
end;
LocalFileList.Enabled:=True;
DriveComboBox1.Enabled:=True;
RemoteFileList.Enabled:=True;
ComboHistory.Enabled:=True;
RemoteUpDir.Enabled:=True;
IsTransParent:=False;
except
QueueList.Items[0].SubItems[3]:='错误';
ShowMessage('上传文件错误!');
LocalFileList.Enabled:=True;
DriveComboBox1.Enabled:=True;
RemoteFileList.Enabled:=True;
ComboHistory.Enabled:=True;
RemoteUpDir.Enabled:=True;
IsTransParent:=False;
end;
end;