各位兄弟:你们好
我在DELPHI使用FTP控件上传程序的时候,老是会报一个错误,说打不开我指定的文件;有时候又可以上传,没有问题的,不知道为什么,我的源程序为:
//=============上传文件=========================
procedure Tfrm_main.BitBtn2Click(Sender: TObject);
var
i: integer;
sfilename: string;
sfile:string;
tempdata: pdata;
begin
for i := 0 to (listview1.Items.Count - 1) do
begin
if listview1.Items[i].Checked then
begin
tempdata := listview1.Items[i].Data;
sfilename := tempdata.filename;
sfile := tempdata.filedesc;
try
nmftp1.Upload(sfile, '');
except
on E: Exception do
showmessage(E.message);
end;
end;
end;
listbox1.Clear;
listbox1.Items.Add('..');
try
nmftp1.List;
except
on E: Exception do
showmessage(E.Message);
end;
nmftp1.Abort;
end;一般都是在 nmftp1.Upload(sfile, '');发生错误,例如说can,t open file c:\hhh.txt;请大侠帮忙!
我在DELPHI使用FTP控件上传程序的时候,老是会报一个错误,说打不开我指定的文件;有时候又可以上传,没有问题的,不知道为什么,我的源程序为:
//=============上传文件=========================
procedure Tfrm_main.BitBtn2Click(Sender: TObject);
var
i: integer;
sfilename: string;
sfile:string;
tempdata: pdata;
begin
for i := 0 to (listview1.Items.Count - 1) do
begin
if listview1.Items[i].Checked then
begin
tempdata := listview1.Items[i].Data;
sfilename := tempdata.filename;
sfile := tempdata.filedesc;
try
nmftp1.Upload(sfile, '');
except
on E: Exception do
showmessage(E.message);
end;
end;
end;
listbox1.Clear;
listbox1.Items.Add('..');
try
nmftp1.List;
except
on E: Exception do
showmessage(E.Message);
end;
nmftp1.Abort;
end;一般都是在 nmftp1.Upload(sfile, '');发生错误,例如说can,t open file c:\hhh.txt;请大侠帮忙!
应该是路径问题,要指定路径。
这里的SFILE如果只是文件名的话肯定会有问题的。
用nmftp1.ChangeDir
nmftp1.ChangeDir修改的只是FTP服务器上的当前路径,本地的好象还是要指定路径的。不过,好象也可以用SetCurrentDirectory指定本地当前路径。