ftp类的一些操作方法
.net,C#,Ftp各种操作,上传,下载,删除文件,创建目录,删除目录,获得文件列表等(转)
using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.IO;
using System.Windows.Forms;
namespace ConvertData
{
class FtpUpDown
{
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;
}
//都调用这个
private string[] GetFileList(string path, string WRMethods)//上面的代码示例了如何从ftp服务器上获得文件列表
{
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;
}
}
public string[] GetFileList(string path)//上面的代码示例了如何从ftp服务器上获得文件列表
{
return GetFileList("doc.guandang.net; + ftpServerIP + "/" + path, WebRequestMethods.Ftp.ListDirectory);
}
public string[] GetFileList()//上面的代码示例了如何从ftp服务器上获得文件列表
{
return GetFileList("doc.guandang.net; + ftpServerIP + "/", WebRequestMethods.Ftp.ListDirectory);
}
public void Upload(string filename) //上面
终止异步FTP操作 已重写。开始以异步方式打开请求的内容流以便写入 已重写。开始... ftp文件上传下载及其他操... 4页 1下载券喜欢此文档的还喜欢...
FTP登陆上传文件使用说明... 3页 1下载券 我们正常用的ftp工具是在... 3...指定的主目录及以下的各级子目录,而不能访问上级目录,便于保证硬盘上其他文件的...
暂无评价0人阅读0次下载举报文档 ftp文件上传、下载使用方法_计算机软件及应用_IT/计算机_专业资料。今日推荐 78份文档 笑翻神图...
用Java 实现 FTP 批量大文件上传下载(一) 本文介绍了在 Java 中,如何使用 ...公开免费的 ftp 客户端类 库,如 simpleftp、J-ftp 等,还有很多其他的 ftp...
用Java 实现 FTP 批量大文件上传下载(一) 本文介绍了在 Java 中,如何使用 ...公开免费的 ftp 客户端类 库,如 simpleftp、J-ftp 等,还有很多其他的 ftp...
ftp 文件上传下载模块概述 1.1 开发背景如果用户不使用 FTP 客户端软件, 而是...( int nColumn = 1; nColumn < m_nNumColumns; nColumn++ ) //设置其他 ...
第8章 FTP文件上传下载 34页 免费 ftp文件上传下载及其他操作... 4页 免费...获取下载券 登录百度文库,专享文档复制特权,财富值每天免费拿!现在就登录>> ...
本文仅以 4.使用API函数实现文件的下载 文件下载和文件上传的步骤基本相同,但使用的是 FtpGetFile函数。在下载之前必须使用FtpFindFirstFile和IntemetFindNextFile...
如何使用FTP上传和下载_电脑基础知识_IT/计算机_专业资料。今日推荐 ... ftp文件上传、下载使用方... 11页 1下载券 使用FTP连接到Linux上传... ...
其他的文件格式,在传输时就以二进制的方式进行。以...FTP 软件都属于此类,而且 FTP 命令及使用方法 基本...下载文件和显示文件目录,拥有写入权限的用户可以上传...
热门文档