當前位置:首頁 » 文件管理 » ftpc源碼

ftpc源碼

發布時間: 2022-09-05 06:34:06

❶ 求一個完美無錯C#的ftp源碼,最好是中文

自己把這些方法寫到一個類里.我分二次回答,一次...您的回答內容多於10000字,請刪減! string ftpServerIP;
string ftpUserID;
string ftpPassword;

FtpWebRequest reqFTP;

private void Connect(String path)//連接ftp
{
// 根據uri創建FtpWebRequest對象
reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(path));
// 指定數據傳輸類型
reqFTP.UseBinary = true;
// ftp用戶名和密碼
reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword);
}

public FtpUpDown(string ftpServerIP, string ftpUserID, string ftpPassword)
{
this.ftpServerIP = ftpServerIP;
this.ftpUserID = ftpUserID;
this.ftpPassword = ftpPassword;
}

//都調用這個
//從ftp伺服器上獲得文件列表
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();
}

// to remove the trailing '\n'
result.Remove(result.ToString().LastIndexOf('\n'), 1);
reader.Close();
response.Close();

return result.ToString().Split('\n');
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
downloadFiles = null;

return downloadFiles;
}
}

//從ftp伺服器上獲得文件列表
public string[] GetFileList(string path)
{
return GetFileList("ftp://" + ftpServerIP + "/" + path,
WebRequestMethods.Ftp.ListDirectory);
}

//從ftp伺服器上獲得文件列表
public string[] GetFileList()
{
return GetFileList("ftp://" + ftpServerIP + "/",
WebRequestMethods.Ftp.ListDirectory);
}

//從ftp伺服器上載文件的功能
public void Upload(string filename)
{
FileInfo fileInf = new FileInfo(filename);
string uri = "ftp://" + ftpServerIP + "/" + fileInf.Name;

Connect(uri);//連接
// 默認為true,連接不會被關閉
// 在一個命令之後被執行
reqFTP.KeepAlive = false;
// 指定執行什麼命令
reqFTP.Method = WebRequestMethods.Ftp.UploadFile;
// 上傳文件時通知伺服器文件的大小
reqFTP.ContentLength = fileInf.Length;
// 緩沖大小設置為kb
int buffLength = 2048;
byte[] buff = new byte[buffLength];

int contentLen;
// 打開一個文件流(System.IO.FileStream) 去讀上傳的文件
FileStream fs = fileInf.OpenRead();

try
{
// 把上傳的文件寫入流
Stream strm = reqFTP.GetRequestStream();
// 每次讀文件流的kb
contentLen = fs.Read(buff, 0, buffLength);

// 流內容沒有結束
while (contentLen != 0)
{
// 把內容從file stream 寫入upload stream
strm.Write(buff, 0, contentLen);
contentLen = fs.Read(buff, 0, buffLength);
}

// 關閉兩個流
strm.Close();
fs.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Upload Error");
}
}

❷ 求C#寫的FTP文件多線程源碼,伺服器客戶端都有就好了。發送到郵箱也行[email protected]

FTP伺服器源碼?難道你自己想實現一個自定義的建議FTP服務嗎?這樣不是不行,關鍵是ftp服務本來就是一種古老的文件共享協議,建立在TCP/IP協議上,這已經是實現了的東西,有自己的通信協議,為什麼還要自己寫一個服務?

要FTP客戶端,負責和伺服器通信的話,倒是有。

❸ 求FTP CLIENT源碼(java

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.StringTokenizer;
import sun.net.TelnetInputStream;
import sun.net.ftp.FtpClient;

public class FtpClientDemo {
public static int BUFFER_SIZE = 10240;
private FtpClient m_client;
// set the values for your server
private String host = "";
private String user = "";
private String password = "";
private String sDir = "";
private String m_sLocalFile = "";
private String m_sHostFile = "";
public FtpClientDemo() {
try {
System.out.println("Connecting to host " + host);
m_client = new FtpClient(host);
m_client.login(user, password);
System.out.println("User " + user + " login OK");
System.out.println(m_client.welcomeMsg);
m_client.cd(sDir);
System.out.println("Directory: " + sDir);
m_client.binary();
System.out.println("Success.");
} catch (Exception ex) {
System.out.println("Error: " + ex.toString());
}
}
protected void disconnect() {
if (m_client != null) {
try {
m_client.closeServer();
} catch (IOException ex) {
}
m_client = null;
}
}
public static int getFileSize(FtpClient client, String fileName)
throws IOException {
TelnetInputStream lst = client.list();
String str = "";
fileName = fileName.toLowerCase();
while (true) {
int c = lst.read();
char ch = (char) c;
if (c < 0 || ch == '\n') {
str = str.toLowerCase();
if (str.indexOf(fileName) >= 0) {
StringTokenizer tk = new StringTokenizer(str);
int index = 0;
while (tk.hasMoreTokens()) {
String token = tk.nextToken();
if (index == 4)
try {
return Integer.parseInt(token);
} catch (NumberFormatException ex) {
return -1;
}
index++;
}
}
str = "";
}
if (c <= 0)
break;
str += ch;
}
return -1;
}
protected void getFile() {
if (m_sLocalFile.length() == 0) {
m_sLocalFile = m_sHostFile;
}
byte[] buffer = new byte[BUFFER_SIZE];
try {
int size = getFileSize(m_client, m_sHostFile);
if (size > 0) {
System.out.println("File " + m_sHostFile + ": " + size
+ " bytes");
System.out.println(size);
} else
System.out.println("File " + m_sHostFile + ": size unknown");
FileOutputStream out = new FileOutputStream(m_sLocalFile);
InputStream in = m_client.get(m_sHostFile);
int counter = 0;
while (true) {
int bytes = in.read(buffer);
if (bytes < 0)
break;
out.write(buffer, 0, bytes);
counter += bytes;
}
out.close();
in.close();
} catch (Exception ex) {
System.out.println("Error: " + ex.toString());
}
}
protected void putFile() {
if (m_sLocalFile.length() == 0) {
System.out.println("Please enter file name");
}
byte[] buffer = new byte[BUFFER_SIZE];
try {
File f = new File(m_sLocalFile);
int size = (int) f.length();
System.out.println("File " + m_sLocalFile + ": " + size + " bytes");
System.out.println(size);
FileInputStream in = new FileInputStream(m_sLocalFile);
OutputStream out = m_client.put(m_sHostFile);
int counter = 0;
while (true) {
int bytes = in.read(buffer);
if (bytes < 0)
break;
out.write(buffer, 0, bytes);
counter += bytes;
System.out.println(counter);
}
out.close();
in.close();
} catch (Exception ex) {
System.out.println("Error: " + ex.toString());
}
}
public static void main(String argv[]) {
new FtpClientDemo();
}
}

❹ 怎麼通過ftp獲取網站源碼

先安裝FTP軟體,推薦flashfxp或cuteftp
然後你需要FTP的IP、埠、FTP賬戶、FTP密碼
再通過FTP軟體鏈接到伺服器,然後就可以下載網站源碼了

❺ 求易語言繞過cfTP安全的源碼

用vmp保護模塊

VMP保護開始()

欲保護的程序

VMP保護結束()

這個是模塊 送上

❻ C語言如何連接FTP,連接成功後遍歷FTP下目錄,包括子目錄,要源代碼,而且是成功案例,自以為是的靠邊站!

用libcurl實現,具體代碼看
http://curl.haxx.se/libcurl/c/ftpget.html

linux下ftp客戶端源碼

sudo apt-get source $packagename
$packagename 換成ftp客戶端名字,如lftp,我猜lftp是最簡單的。
其他常見的有
kftpgrabber
KDE下ftp客戶端,支持編碼選擇。對中文支持較好
gftp
gnome下ftp客戶端,目前對中文支持尚不太好,受抱怨頗多。
fireftp
firefox的ftp客戶端插件,新版對中文支持較好。
FileZilla
對中文支持較好
CrossFTP
基於Java的穩定ftp客戶端和同步工具。優良的中文/Unicode支持。

❽ C語言實現從FTP下載、上傳文件

FTP 是File Transfer Protocol(文件傳輸協議)的英文簡稱,而中文簡稱為「文傳協議」。
1.C語言可以使用CStdioFile函數打開本地文件。使用類CInternetSession 創建並初始化一個Internet打開FTP伺服器文件。
CStdioFile繼承自CFile,一個CStdioFile 對象代表一個用運行時函數fopen 打開的C 運行時流式文件。
流式文件是被緩沖的,而且可以以文本方式(預設)或二進制方式打開。文本方式提供對硬回車—換行符對的特殊處理。當你將一個換行符(0x0A)寫入一個文本方式的CStdioFile 對象時,位元組對(0x0D,0x0A)被發送給該文件。當你讀一個文件時,位元組對(0x0D,0x0A)被翻譯為一個位元組(0x0A)。
CStdioFile 不支持Duplicate,LockRange,和UnlockRange 這幾個CFile 函數。如果在CStdioFile 中調用了這幾個函數,將會出現CNoSupported 異常。
使用類CInternetSession 創建並初始化一個或多個同時的Internet 會話。如果需要,還可描述與代理伺服器的連接。
如果Internet連接必須在應用過程中保持著,可創建一個類CWinApp的CInternetSession成員。一旦已建立起Internet 會話,就可調用OpenURL。CInternetSession會通過調用全局函數AfxParseURL來為分析映射URL。無論協議類型如何,CInternetSession 解釋URL並管理它。它可處理由URL資源「file://」標志的本地文件的請求。如果傳給它的名字是本地文件,OpenURL 將返回一個指向CStdioFile對象的指針。
如果使用OpenURL在Internet伺服器上打開一個URL,你可從此處讀取信息。如果要執行定位在伺服器上的指定的服務(例如,HTTP,FTP或Gopher)行為,必須與此伺服器建立適當的連接。

❾ 怎樣用c或c++語言編寫ftp程序 客戶端和伺服器端的源代碼

這個問題太大了點,你可以去starforge等開源網站上去找這方面的工程。。。

❿ 諸位大神誰有java 實現FTP客戶端的源碼

您好,/ **
*創建日期:2008年12月23日

*類名:Ftp.java

*類路徑:組織結構

*更改日誌:

* / 包組織結構;

進口的java.io.File;

進口java.io.FileInputStream中;

進口java.io.FileOutputStream中;

進口的java。 io.IOException;

進口sun.net.TelnetInputStream;

進口sun.net.TelnetOutputStream;

進口sun.net.ftp.FtpClient;

> / **

* @作者南山地獄

* @說明FTP操作

* /

公共類的Ftp {

/ **

* BR />獲取FTP目錄* / 公共無效getftpList(){

字元串伺服器=「IP地址 /輸入FTP伺服器/>弦樂用戶=」「;/ / FTP伺服器的登錄用戶名

字元串密碼=「」;/ /登錄FTP伺服器的用戶名

字元串路徑密碼=「」;/ / FTP路徑上的伺服器

嘗試{
> FtpClient的FTP客戶端=新FtpClient的();/ /創建FtpClient的對象

ftpClient.openServer(伺服器);/ /連接到FTP伺服器

ftpClient.login(用戶名,密碼);/ / FTP伺服器 BR />如果(path.length()= 0){

ftpClient.cd(路徑);

}

TelnetInputStream是= ftpClient.list();

詮釋三;

而{

System.out.print((char)的C)((C = is.read())= -1!);

}

掉} is.close ();

ftpClient.closeServer();/ /退出FTP伺服器

}趕上(IOException異常前){

System.out.println(ex.getMessage());

}

}

/ **

*
* /

公共無效getFtpFile(){

字元串伺服器=「」;/ / IP地址中輸入FTP伺服器

弦樂用戶=「」;/ / FTP伺服器的登錄用戶名

字元串密碼=「」;/ /登錄密碼為FTP伺服器的用戶名

字元串路徑=「路徑

字元串文件名「;/ /上=的FTP伺服器」「;/ /下載文件名稱

嘗試{

FtpClient的FTP客戶端=新FtpClient的();

ftpClient.openServer(伺服器);

ftpClient.login(用戶名,密碼);

如果(路徑。長度()= 0)

ftpClient.cd(路徑);!

ftpClient.binary();

TelnetInputStream是= ftpClient.get(文件名);

文件file_out =新的文件(文件名);

文件輸出流OS =新的文件輸出流(file_out);

位元組[]位元組=新位元組[1024];

詮釋三;

而((C = is.read(位元組))= -1){

os.write (位元組,0,C);

}!

掉} is.close();

os.close();

ftpClient.closeServer();

}趕上(IOException異常前){

System.out.println (ex.getMessage());

}

FTP}

/ **

*文件上傳到FTP

* /

公共無效putFtpFile() {

字元串伺服器=「」;/ /輸入IP地址對伺服器

字元串用戶的地址=「」;/ / FTP伺服器的登錄用戶名

字元串密碼=「」;/ / FTP伺服器登錄用戶名密碼

字元串路徑=「」就 / FTP伺服器/>字元串文件名=「」;/ /上傳的文件名

FtpClient的FTP客戶端=新的try { FtpClient的();

ftpClient.openServer(伺服器);

ftpClient.login(用戶名,密碼);

如果(!path.length()= 0)

ftpClient.cd (路徑);

ftpClient.binary();

TelnetOutputStream OS = ftpClient.put(文件名);

文件file_in =新的文件(文件名);

文件輸入流是=新的文件輸入流(file_in);

位元組[]位元組=新位元組[1024];

詮釋三;

同時(! (C = is.read(位元組))= -1){

操作系統。寫(位元組,0,C);

}

掉} is.close();

os.close();

ftpClient.closeServer();

}趕上(IOException異常前){

System.out.println(ex.getMessage());

}

}
}

熱點內容
網站架設多伺服器ip 發布:2024-10-12 07:42:15 瀏覽:187
linuxjdbc 發布:2024-10-12 07:38:10 瀏覽:197
pythonip正則表達式 發布:2024-10-12 07:30:24 瀏覽:177
xp怎麼認安卓手機 發布:2024-10-12 07:30:20 瀏覽:878
pythonmac開發工具 發布:2024-10-12 07:29:01 瀏覽:267
android字元數組 發布:2024-10-12 07:16:32 瀏覽:307
買安卓手機選什麼顏色 發布:2024-10-12 07:10:51 瀏覽:698
已經連接的wifi怎麼看密碼 發布:2024-10-12 07:06:07 瀏覽:59
sae上傳失敗 發布:2024-10-12 07:03:20 瀏覽:958
如何在伺服器上玩ai換臉 發布:2024-10-12 06:43:47 瀏覽:913