怎么遍历ftp服务器里面某个文件夹下的文件
答案:2 悬赏:0 手机版
解决时间 2021-01-29 10:42
- 提问者网友:棒棒糖
- 2021-01-28 19:52
怎么遍历ftp服务器里面某个文件夹下的文件
最佳答案
- 五星知识达人网友:骨子里都是戏
- 2021-01-28 20:40
packagecom.hmilyld.exp;importjava.io.File;publicclassListFile{privatelong[]count=newlong[]{0,0};privateFilefile;privatelong[]listFile(Stringpath){file=newFile(path);File[]f=file.listFiles();for(inti=0;i
全部回答
- 1楼网友:天凉才是好个秋
- 2021-01-28 22:08
///
/// 获取当前目录下明细(包含文件和文件夹)
///
///
public string[] getfilesdetaillist()
{
string ftpuri = "ftp://10.86.86.86";
string ftpuserid = "sa";
string ftppassword = "sa";
string[] downloadfiles;
try
{
stringbuilder result = new stringbuilder();
ftpwebrequest ftp;
ftp = (ftpwebrequest)ftpwebrequest.create(new uri(ftpuri));
ftp.credentials = new networkcredential(ftpuserid, ftppassword);
ftp.method = webrequestmethods.ftp.listdirectorydetails;
webresponse response = ftp.getresponse();
streamreader reader = new streamreader(response.getresponsestream(), encoding.default);
string line = reader.readline();
while (line != null)
{
result.append(line);
result.append("\n");
line = reader.readline();
}
result.remove(result.tostring().lastindexof("\n"), 1);
reader.close();
response.close();
return result.tostring().split('\n');
}
catch (exception ex)
{
downloadfiles = null;
return downloadfiles;
}
}
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯