最近的工作中,需要定時操作ftp伺服器上的檔案,用到了ftpclient
記錄並分享一下使用心得
首先當然是引包 commons-net-2.0.jar
這樣你就可以使用ftpclient這個類建立用於連線ftp伺服器的物件了
具體方法見**:
以下是連線到ftp伺服器的**,返回true 就代表ftpclient已經成功連線到ftp伺服器了,也就是可以操作ftp伺服器上的檔案了ftpclient ftpclient = new ftpclient();
private string serverip;
private integer port;
private string username;
private string password;
下面再來兩個操作檔案的方法做演示public boolean getready()
if(!succeed)else
} catch (exception exp)
} return succeed;
}
獲取檔案列表(當然返回的是檔名集合)
刪除ftp指定檔案(小心操作哦)public listlist(string filepath)
}} catch (ioexception e)
} return result;
}
以上只做簡單介紹,希望對初次使用的有引導作用/**
* 刪除指定檔案
* @param pathname
* @return
* @throws ioexception
*/public void deletefile(string pathname)
} catch (exception e)
}
使用cmd連線操作ftp伺服器
通過cmd命令列方式連線和操作ftp伺服器 c documents and settings administrator ftp ftp help commands may be abbreviated.commands are delete literal prompt send debug ls...
Linux伺服器上搭建FTP服務
安裝 vsftpd0 使用 yum 安裝 vsftpd yum install vsftpd y啟動 vsftpd0 安裝完成後,啟動 ftp 服務 service vsftpd start啟動後,可以看到系統已經監聽了 21 埠 netstat nltp grep 21修改配置檔案 vsftpd ...
Ftp伺服器檔案操作
using system using system.collections.generic using system.text using system.io using system.net using system.windows.forms using system.globalization...