當前位置:首頁 » 文件傳輸 » 文件名獲取ftp文件
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

文件名獲取ftp文件

發布時間: 2023-01-12 23:16:27

A. FTP獲取文件名以及文件路徑

既然是伺服器,而且是linux 你用一個tomcat 當做伺服器,可以配置一下tomcat,就可以直接ftp 模式訪問文件夾了。

B. 用bat批處理命令獲取ftp伺服器目錄下的文件名及子目錄下的文件名...各位大神幫幫忙

@echooff
seth=192.168.1.100
setu=ftpuser
setp=12345678
echoopen%h%>ftp.txt
echo%u%>>ftp.txt
echo%p%>>ftp.txt
echodir>>ftp.txt
echobye>>ftp.txt
ftp-s:ftp.txt>ftpdir.txt
echoopen%h%>ftp.txt
echo%u%>>ftp.txt
echo%p%>>ftp.txt
for/f"tokens=4"%%iin('findstr"<DIR>"ftpdir.txt')do(
echocd%%~i>>ftp.txt
echodir>>ftp.txt
echocd..>>ftp.txt)
echobye>>ftp.txt
ftp-s:ftp.txt>ftpfile.txt
notepadftpfile.txt

C. 如何進行FTP文件的搜索

FTP文件伺服器由一些組織結構為內部方柏霓而搭建的,如醫院,學校、政府等,相當於集團的雲端一樣,實時的進行數據共享,發圖片文件伺服器會消耗很大的寬頻資源,佔用較大的網速,而且不盈利,在非公益組織的ftp是不允許他人登陸的,所以一般市面上並不常見。

通過遠程連接ftp即可連接登陸,然後就能夠下載所需文件了,但是要知道區域網的ip,登陸可能還需要賬號及密碼,使用伺服器管理工具即可登陸連接,既方便,又快捷。

D. windowsftp如何獲取文件夾下所有的文件

可以通過命令窗口來打開所有的文件。具體步驟如下:
點擊win+R後輸入cmd打開dos命令窗口。
打開需獲取文件名的位置。
獲取名稱,命令格式:dir/b文件目標盤符文件夾位置(可省略)目標名稱.目標後綴。
獲取文件大小及文件名、修改時間(文件大小需處理)。
Microsoft Surface是一個由微軟所開發的第一款平面電腦,結合硬體與軟體的新技術,用家可以直接用手或聲音對屏幕作出指令,觸摸和其他外在物理物來和電腦進行交互,毋須再依賴會令手部勞損的滑鼠與鍵盤。

E. 怎麼用ftp 取文件 命令

熟悉並靈應用FTP內部命令便使用者並收事半功倍效
FTP命令行格式:ftp -v -d -i -n -g [主機名]其
-v顯示遠程伺服器所響應信息;
-n限制ftp自登錄即使用;
.n etrc文件;
-d使用調試式;
-g取消全局文件名
ftp使用內部命令(括弧表示選項):
1.![cmd[args]]:本機執行交互shellexitftp環境:!ls*.zip.
2.$ macro-ame[args]:執行宏定義macro-name.
3.account[password]:提供登錄遠程系統功訪問系統資源所需補充口令
4.append local-file[remote-file]:本文件追加遠程系統主機若未指定遠程系統文件名則使用本文件名
5.ascii:使用ascii類型傳輸式
6.bell:每命令執行完畢計算機響鈴
7.bin:使用二進制文件傳輸式
8.bye:退ftp程
9.case:使用mget遠程主機文件名寫轉寫字母
10.cd remote-dir:進入遠程主機目錄
11.cp:進入遠程主機目錄父目錄
12.chmod mode file-name:遠程主機文件file-name存取式設置mode:chmod 777 a.out
13.close:斷與遠程伺服器ftp(與open應)
14.cr:使用asscii式傳輸文件車換行轉換行

F. 如何 用Java 實現 獲取FTP伺服器上的所有文件名,已知FTP的密碼,用戶名!遠程獲取!

public void ftpJdomFile(String dir) throws FileNotFoundException, IOException{
//創立根節點
// 下面這個方法是列出指定目錄下的所有文件和文件夾
List dirslist=Arrays.asList(new File(dir).listFiles());
for (Iterator i = dirslist.iterator(); i.hasNext();) {
// System.out.println(i.next()); // line 1
String s=i.next().toString();
if (new File(s).isFile()) {
System.out.println(s+"-文件");
}
if (new File(s).isDirectory()) {
System.out.println(s+"++++++++文件夾");
ftpJdomFile(s);
}

}

}

G. Linux下如何獲取FTP文件名和大小

path='' #這里的$1,換成你需要的路徑名,或者你不換,通過shell的參數傳入
for dirlist in $(find ${path} -name *.xml)
do
echo ${dirlist}
查找,刪除,比較都在這做
done

H. C# 獲取Ftp某個目錄下的所有文件(不要文件夾)

我在之前做過一個FTP的客戶端工具。
drw 文件夾
-rw 文件(有擴展名或無擴展名)
我是根據服務端返回的報文進行分析獲取的列表。
給你一些代碼片段:
/// <summary>
/// 獲取指定目錄下的文件和文件夾。
/// </summary>
/// <param name="path">要獲取的目錄</param>
/// <param name="WRMethods">要發送到FTP伺服器的密令。</param>
/// <returns></returns>
public string[] GetFileList(string path, string WRMethods)//從ftp伺服器上獲得文件列表
{
WebResponse response;
string[] downloadFiles;
int conut = 4;
StringBuilder result = new StringBuilder();
Connect(path);
if (FTPVariable.IsUseProxy_ftp)
{
reqFTP.Proxy = FtpProxy.GetFtpSelectProxy(FTPVariable.FtpCommand_transferProxyName);
}
reqFTP.ReadWriteTimeout = 12000;
//如果不應銷毀到伺服器的連接,則為 true;否則為 false。默認值為 true。
//
reqFTP.Method = WRMethods;
try
{
response = (FtpWebResponse)reqFTP.GetResponse();
goto Ftp_lbl_03;
}
catch (WebException webex)
{
GetReply(webex.Message);
if (ReplyCode == 530)// 未登錄。
{
goto Ftp_lbl_04;
}
else if (ReplyCode == 550)
{
goto Ftp_lbl_04;
}
else
{
FtpManage.SetLog("獲取列表超時,等候1秒後重試!");
goto Ftp_lbl_01;
}
}
Ftp_lbl_01:
try
{
FtpManage.SetLog("正在連接伺服器 " + FtpRemoteHost);
response = GetRequest(path, WRMethods);
}
catch (WebException)
{
FtpManage.SetLog("獲取列表超時,等候1秒後重試!");
downloadFiles = null;
System.Threading.Thread.Sleep(1000);
if (conut == 0)
{
goto Ftp_lbl_02;
}
conut--;
goto Ftp_lbl_01;
}
catch (Exception ex)
{
MSG.Show(ex.Message, Global.GetRS["msgTilteError"], MessageBoxButton.OK, MsgIco.Error);
FtpManage.SetLog("命令執行失敗,原因:" + ex.Message);
downloadFiles = null;
return downloadFiles;
}
Ftp_lbl_03:
StreamReader reader = new StreamReader(response.GetResponseStream(), System.Text.Encoding.Default);//中文文件名
string line = reader.ReadLine();
while (line != null)
{
result.Append(line);
result.Append("\n");
line = reader.ReadLine();
}
if (result.Length == 0)
{
return null;
}
// to remove the trailing '\n'
result.Remove(result.ToString().LastIndexOf('\n'), 1);
reader.Close();
response.Close();
FtpManage.SetLog("命令已成功執行");
return result.ToString().Split('\n');
Ftp_lbl_04:
FtpManage.SetLog(ReplyInfo);
return null;
Ftp_lbl_02:
FtpManage.SetLog("550 獲取列表失敗,無法連接遠程伺服器!");
FtpManage.ftpmanage.IsRefurbish = true;
return null;
}
/// <summary>
/// 獲取指定目錄下的文件和文件夾。
/// </summary>
/// <param name="path">要獲取的目錄</param>
/// <returns></returns>
public string[] GetFileList(string path)//從ftp伺服器上獲得文件列表
{
return GetFileList(FTPVariable.FtpURLhead + FtpRemoteHost + "/" + path, WebRequestMethods.Ftp.ListDirectory);
}

/// <summary>
/// 獲取指定目錄下的文件和文件夾。
/// </summary>
/// <returns></returns>
public string[] GetFileList()//從ftp伺服器上獲得文件列表
{
return GetFileList(FTPVariable.FtpURLhead + FtpRemoteHost + "/", WebRequestMethods.Ftp.ListDirectory);
}

/// <summary>
/// 獲取目錄和文件名,返回目錄表。
/// </summary>
/// <param name="path">要獲取的目錄</param>
/// <returns></returns>
public string[] GetCatalog_FileList(string path)
{
string[] fountainhead = GetFileList(FTPVariable.FtpURLhead + FtpRemoteHost + "/" + path, WebRequestMethods.Ftp.ListDirectoryDetails);
string[] Catalog = null;
if (fountainhead == null)
{
return null;
}
Catalog = new string[fountainhead.Length];
for (int i = 3; i < fountainhead.Length; i++)
{
Catalog[i - 3] += fountainhead[i].Substring(55, fountainhead[i].Length - 55) + "&";//FileName
Catalog[i - 3] += fountainhead[i].Substring(30, 12) + "&";//FileSize
Catalog[i - 3] += fountainhead[i].Substring(42, 13) + "&";//AmendDate
Catalog[i - 3] += fountainhead[i].Substring(0, 3) + "&";
}
return Catalog;
}

I. C#如何取得ftp上面的所有文件夾裡面的所有文件名,求源碼。。。。

連接方法:
string ftpServerIP = "";

string ftpUserID = "";

string ftpPassword = "";

string TempPath = Path.GetTempPath();

FtpWebRequest reqFTP;
DataTable dt;
private void Connect(String path)//連接ftp
{

try
{
reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(path));
reqFTP.UseBinary = true;
reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword);
}
catch (Exception){
Response.Write("<srcipt>alert('連接失敗!')</script>");
}
獲取方法:
private string[] GetFileList(string path, string WRMethods)
{
string[] downloadFiles;
StringBuilder result = new StringBuilder();
try
{
Connect(path);
reqFTP.Method = WRMethods;
WebResponse response = reqFTP.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream(), System.Text.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)
{

downloadFiles = null;

return downloadFiles;
}
}
調用:
string[] str = GetFileList("ftp://" + ftpServerIP + "/" + path, WebRequestMethods.Ftp.ListDirectoryDetails);

數組就是ftp文件夾下的所有文件名,如果要判斷ftp根下面的是文件還是文件夾。需要解字元串才行!