当前位置:首页 » 文件管理 » ftp遍历文件夹

ftp遍历文件夹

发布时间: 2022-07-28 13:58:23

A. java ftp遍历文件问题

我怀疑 ftp 根目录你没有权限


你尝试着 调用 带参的listFiles方法

FTPFile[]ftpFiles=ftpClient.listFiles(remotePath);

B. 怎么遍历ftp服务器里面某个文件夹下的文件

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

C. winform怎么遍历ftp上指定目录下的所有文件

我在之前做过一个FTP的客户端工具。 drw 文件夹 -rw 文件(有扩展名或无扩展名) 我是根据服务端返回的报文进行分析获取的列表。 给你一些代码片段: /// /// 获取指定目录下的文件和文件夹。 /// /// 要获取的目录 /// 要发送到FTP服务器的密令

D. ftp遍历目录的问题

你这个ftp是用的都是同一个对象,每次递归workfolder都被update掉了。。。。当然会不继续遍历,改成每次都Generate一个New的ftp吧。
补充:
本来你ftp指向目录A,后来进入递归被改成指向A/B了,你说遍历还能准确吗?
还有个方法就是每次递归回来调用:
ftp.changeWorkingDirectory(ftpPath);
把Path给设置回来。不过不确定这个方法稳定,可以先Try一下。
public void listFilesDir(String path) throws IOException{
String ftpPath = path;
ftp.changeWorkingDirectory(ftpPath);
FTPFile[] files = ftp.listFiles();
for(FTPFile ff:files){
if(!ff.isDirectory()){
System.out.println("文件:" + ff.getName());
}
else{
if(!ff.getName().startsWith(".")){
ftpPath = ff.getName() + "/";
System.out.println("目录 " + ff.getName() + " 下的文件文件或目录:");
ftp.changeWorkingDirectory(ftpPath);
listFilesDir(ftpPath);
ftp.changeWorkingDirectory(path);
}
}
}
}
再补充:
中文的话试试看用GBK。。。Java项目的编码记得也要一样的。

E. AU3有什么FTP函数能遍历上传一个文件夹下的文件

试编写代码如下: <?php$dir="D:/WWW/ftp"; //指定的路径$sitepath = '中国//localhost/ftp/';//遍历文件夹下所有文件if (false != ($handle = opendir ( $dir ))) { echo "$dir 目录下的文件列表:
"; $i = 0; while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && !is_dir($dir.'/'.$file)) { echo ''.$file. '
'; } } //关闭句柄 closedir($handle);}?> 代码中需要提示的是: 如果是运行于互联中国上,需要考虑文件的访问安全性。 运行截图

F. c# 如何遍历ftp文件夹下的文件

ftp文件是一样的
只不过路径的格式不一样而已

这个文件太长了 给我信箱给你发过去吧
using System;
using System.Net;
using System.IO;
using System.Text;
using System.Net.Sockets;

namespace zhangyuk.net.csdn.blog.ftpclient
{
/// <summary>
/// FTP Client
/// </summary>
public class FTPClient
{
#region 构造函数
/// <summary>
/// 缺省构造函数
/// </summary>
public FTPClient()
{
strRemoteHost = " ";
strRemotePath = " ";
strRemoteUser = " ";
strRemotePass = " ";
strRemotePort = 21;
bConnected = false;
}

/// <summary>
/// 构造函数
/// </summary>
/// <param name= "remoteHost "> </param>
/// <param name= "remotePath "> </param>
/// <param name= "remoteUser "> </param>
/// <param name= "remotePass "> </param>
/// <param name= "remotePort "> </param>
public FTPClient( string remoteHost, string remotePath, string remoteUser, string remotePass, int remotePort )
{
strRemoteHost = remoteHost;
strRemotePath = remotePath;
strRemoteUser = remoteUser;
strRemotePass = remotePass;
strRemotePort = remotePort;
Connect();
}
#endregion

#region 登陆
/// <summary>
/// FTP服务器IP地址
/// </summary>
private string strRemoteHost;
public string RemoteHost
{
get
{
return strRemoteHost;
}
set
{
strRemoteHost = value;
}
}
/// <summary>
/// FTP服务器端口
/// </summary>
private int strRemotePort;
public int RemotePort
{
get
{
return strRemotePort;
}
set
{
strRemotePort = value;
}
}
/// <summary>
/// 当前服务器目录
/// </summary>
private string strRemotePath;
public string RemotePath
{
get
{
return strRemotePath;
}
set
{
strRemotePath = value;
}
}
/// <summary>
/// 登录用户账号
/// </summary>
private string strRemoteUser;
public string RemoteUser
{
set
{
strRemoteUser = value;
}
}
/// <summary>
/// 用户登录密码
/// </summary>
private string strRemotePass;
public string RemotePass
{
set
{
strRemotePass = value;
}
}

/// <summary>
/// 是否登录
/// </summary>
private Boolean bConnected;
public bool Connected
{
get
{
return bConnected;
}
}
#endregion

G. C#如何实现FTP在服务器上遍历文件夹

.../Image这个主文件夹是一定的,然后搂住是想在这个文件夹下创建文件夹
事先,你已经知道你所要创建的文件夹的名称,可以这么做
if (!(Directory.Exists(path+文件名))//用这个方法判断是否有这个文件夹。比你去遍历文件夹要效率的多
Directory.CreateDirectory(path+文件名);//不存在则创建

H. java写的ftp程序~~怎么遍历文件

//这是一个计算指定目录所包含文件的总大小的函数
//当然涉及了遍历文件及文件夹
void getLength(File file)
{
if(file.isDirectory())
{
File fileArray[]=file.listFiles();
for(int i=0;i<fileArray.length;i++){
getLength(fileArray[i]); //System.out.println(fileArray[i].getPath());
}
}
else if(file.isFile()){
try
{
RandomAccessFile raf=new RandomAccessFile(file,"r");
fileLength=fileLength+raf.length();
raf.close();
}catch(IOException ioe){ioe.printStackTrace();}
}
}

I. 如何遍历列出ftp下目录及子目录

import java.io.File;

public class ListFile {

private long[] count = new long[] { 0, 0 };

private File file;

private long[] listFile(String path) {
file = new File(path);
File[] f = file.listFiles();
for (int i = 0; i < f.length; i++) {
if (f[i].isDirectory()) {
count[0]++;
this.listFile(f[i].getPath());
} else {
count[1]++;
}
}
return count;
}

/**
* 得到指定路径下的文件和文件夹数量
*
* @param path
* 要查看的路径
* @return object[0]耗时(毫秒)<br>
* object[1]文件夹数量<br>
* object[2]文件数量
*/
public Object[] getFileCount(String path) {
long t = System.currentTimeMillis();
long[] count = this.listFile(path);
t = System.currentTimeMillis() - t;
Object[] o = new Object[] { Long.valueOf(t), Long.valueOf(count[0]),
Long.valueOf(count[1])};
return o;
}

public static void main(String[] args) {
ListFile l = new ListFile();
Object[] count = l.getFileCount("d:\\");
System.out.println(count[0]);
System.out.println(count[1]);
System.out.println(count[2]);
}
}

java写的一个获取目录下有多少文件和多少文件夹的代码,
可以参考下.:)

J. 怎么样遍历ftp文件夹,您的这种写法好像不行,连接不到网络

写不写都行,写得话就直接进入该目录。用ie话在地址里打ftp://用户名:密码@网址:端口一般下ftp用软件最好了,推荐你用flashfxp

热点内容
脚本故事梗 发布:2024-05-18 18:29:02 浏览:822
安卓和csharp哪个发展好 发布:2024-05-18 18:09:30 浏览:527
换编程题库 发布:2024-05-18 18:00:58 浏览:562
如何使用服务器ip直连网站 发布:2024-05-18 18:00:49 浏览:432
三星n7100哪个安卓版本好用 发布:2024-05-18 17:55:41 浏览:490
万国觉醒采集脚本源码 发布:2024-05-18 17:55:39 浏览:947
sqlserver加字段 发布:2024-05-18 17:54:53 浏览:928
安卓手机如何清除应用记录 发布:2024-05-18 17:31:37 浏览:640
查看存储过程权限 发布:2024-05-18 17:18:33 浏览:192
php类self 发布:2024-05-18 17:15:03 浏览:895