當前位置:首頁 » 文件管理 » 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

熱點內容
roblox跑酷腳本怎麼做 發布:2024-05-05 03:57:35 瀏覽:701
捷徑清理緩存 發布:2024-05-05 03:57:35 瀏覽:478
ftputility哪裡下載 發布:2024-05-05 03:47:13 瀏覽:1000
雷凌運動版如何連接安卓手機導航 發布:2024-05-05 03:42:48 瀏覽:267
自動鬼使黑腳本 發布:2024-05-05 03:10:49 瀏覽:880
游戲腳本編程書籍推薦 發布:2024-05-05 02:59:13 瀏覽:72
編譯器書籍推薦 發布:2024-05-05 02:57:02 瀏覽:56
電池存儲溫度 發布:2024-05-05 02:53:07 瀏覽:207
安卓在美國怎麼下載 發布:2024-05-05 02:31:06 瀏覽:925
黑莓存儲空間 發布:2024-05-05 02:19:50 瀏覽:275