当前位置:首页 » 文件管理 » 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());

}

}
}

热点内容
网站编程培训 发布:2024-10-12 06:09:22 浏览:900
怎么看自己的电脑配置玩永劫无间 发布:2024-10-12 05:56:41 浏览:467
linuxzip文件解压命令 发布:2024-10-12 05:56:03 浏览:942
java怎么处理高并发 发布:2024-10-12 05:55:25 浏览:765
五子棋java源码 发布:2024-10-12 05:37:13 浏览:175
pythonopenstack怎么配置 发布:2024-10-12 05:16:07 浏览:929
安卓如何编辑动画 发布:2024-10-12 05:14:25 浏览:348
视频电脑配置高怎么玩游戏 发布:2024-10-12 04:35:56 浏览:731
sql复合查询 发布:2024-10-12 04:14:23 浏览:715
把文档加密 发布:2024-10-12 04:13:52 浏览:852