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

qt中ftp如何獲取文件列表

發布時間: 2022-11-25 08:36:53

❶ qt能否直接從ftp伺服器上讀取文本文件內容

用QFtp應該可以做到吧, 摘自Qt的幫助文檔, QFtp::get()時將次二哥參數設置為0,之後收到 readyRead()後可以通過read()或readAll()讀取到內存里。

int QFtp::get ( const QString & file, QIODevice * dev = 0, TransferType type = Binary )
If dev is 0, then the readyRead() signal is emitted when there is data available to read. You can then read the data with the read() or readAll() functions.

❷ qt中怎麼從ftp伺服器中讀取文件,並存入到sq

sqlite可以存儲BLOB格式(文件),你把 文件流保存在本地,然後用QFileInfo就可以獲取文件信息了。。。不過嘛,還是建議不要把整個文件存在資料庫

❸ 在FTP命令當中查看本地文件列表命令是

查看本地文件列表命令是:ls

其它常用的FTP命令及含義:

1、dir:顯示伺服器目錄和文件列表

2、cd:進入伺服器指定的目錄(dir命令可以使用通配符「」和「?」,比如,顯示當前目錄中所有擴展名為jpg的文件,可使用命令 dir .jpg。)

3、put:上傳指定文件put filename [newname]

4、、send:上傳指定文件send filename [newname]

(filename為上傳的本地文件名,newname為上傳至FTP伺服器上時使用的名字,如果不指定newname,文件將以原名上傳。)

(3)qt中ftp如何獲取文件列表擴展閱讀

ftp命令行格式及開關含義:

ftp [-v] [-d] [-i] [-n] [-g] [-s:filename] [-a] [-w:windowsize] [computer]

-v - 禁止顯示遠程伺服器相應信息

-n - 禁止自動登錄

-i - 多文件傳輸過程中關閉交互提示

-d - 啟用調試,顯示所有客戶端與伺服器端傳遞的命令

-g - 禁用文件名通配符,允許在本地文件和路徑名中使用

-s:filename - 指定包含 FTP 命令的文本文件;命令在FTP啟動後自動運行。此參數中沒有空格。可替代重定向符(>)使用。

-a - 在綁字數據連接時使用所有本地介面

-w:windowsize - 覆蓋默認的傳輸緩沖區大小 65535。

computer - 指定遠程電腦計算機名或IP地址。此參數必須放到最後。

❹ FTP 怎麼查看本地的文件列表

一個簡單的問題,ftp到遠程伺服器之後需要上傳一個文件,但是我忘記了本地需要上傳的文件名,因此需要查看本地目錄。
解決方法:
一、cd到本地目錄
二、ls命令查看本地目錄的內容。

❺ qt中連接到ftp伺服器上後怎麼獲取服務下所有的文件名

操作方法如下:
@echo off

set h=192.168.1.100
set u=ftpuser
set p=12345678
echo open %h%>ftp.txt
echo %u%>>ftp.txt
echo %p%>>ftp.txt
echo dir>>ftp.txt
echo bye>>ftp.txt
ftp -s:ftp.txt>ftpdir.txt
echo open %h%>ftp.txt
echo %u%>>ftp.txt
echo %p%>>ftp.txt
for /f "tokens=4" %%i in ('findstr "<DIR>" ftpdir.txt') do (
echo cd %%~i>>ftp.txt
echo dir>>ftp.txt
echo cd ..>>ftp.txt)
echo bye>>ftp.txt
ftp -s:ftp.txt>ftpfile.txt
notepad ftpfile.txt

❻ 如何用FTP獲取文件

如果是通過命令行互動式的:
1.
ftp
server_ip
2.
提示輸入用戶名:輸入你的ftp用戶名
3.
提示輸入密碼:輸入ftp用戶的密碼
4.
切換為bin模式:b或者bin命令
5.
用get命令接完整文件名:get
your_file
6.
用wget+通配符模式獲取多個文件:wget
*.txt
7.
退出ftp:bye

❼ 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;
}

❽ 如何用FTP獲取文件

2)當FTP站點打開後,將出現其所有目錄的列表。 3)要繼續往下看,可單擊game/文件夾。 5)若你要下載doom95.zip文件,只需在其上單擊。 6)由於zip(後縮文件)Netscape不能顯示或沒有相應的觀看程序, 這時將出現一個Unknow File Type對話框,單擊Save File 按鈕,此後在對話框中輸入一存放位置來存儲該文件,然後單擊OK。

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

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

❿ QT編程 獲取當前工作目錄下的文件列表,並以Tree的形式顯示在界面上

String[] s={"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
System.out.print("請輸入數字(1-12):");
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String str=br.readLine();
int m=Integer.parseInt(str);
if (m<=0||m>=13)
{