做一个文件传送的系统(局域网),SERVER端接收文件,CLIENT端发送文件。
我想问的是:
1.C#中关于FTP有没有封装好的东西
2.采用SOCKET直接将client端的文件名和文件内容发送过去,server端建立一个同名文件写入这样是否可行
3.就上面的做法,ZIP、RAR文件能否在建立后顺利解压谢谢大家,或者谁有现成的FTP或者只要是文件传送的源能够给小弟看一眼,不胜感谢
E-MAIL:[email protected]
我想问的是:
1.C#中关于FTP有没有封装好的东西
2.采用SOCKET直接将client端的文件名和文件内容发送过去,server端建立一个同名文件写入这样是否可行
3.就上面的做法,ZIP、RAR文件能否在建立后顺利解压谢谢大家,或者谁有现成的FTP或者只要是文件传送的源能够给小弟看一眼,不胜感谢
E-MAIL:[email protected]
解决方案 »
- 《C#线程参考手册》代码 在那里有?
- 还是reportView
- 一般.NET上大家换皮肤用什么工具
- DateTime.Parse()怎么返回毫秒?
- 急急,关于打印控制中打印宽度高度及自定义纸张的代码
- <a href="/2374390814/follow"></a>
- c#学习群1909991,欢迎志同道合的朋友加入!让我们一起进步!
- C# winform 如何获取本地计算机的DPI?
- 一个简单的数据库表设计思路问题,在线等!!!!!!
- 《C# Web编程》和《C# Windows编程》这两本书怎么样啊?有没有人看过的?
- C#中如何捕获将数据 更新到数据源的 变动信息!!
- 关于WinForm 窗体添加到Panel后,如何显示在最前方
第二种方法比较方便,但是有局限性,需要C/S结构,
VB里有正对FTP的控件,C#里没用过,不清楚有没有
using System.IO;
using System.Net;
using System.Text;namespace Examples.System.Net
{
public class WebRequestGetExample
{
public static void Main ()
{
// Get the object used to communicate with the server.
FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://www.contoso.com/test.htm");
request.Method = WebRequestMethods.Ftp.DownloadFile; // This example assumes the FTP site uses anonymous logon.
request.Credentials = new NetworkCredential ("anonymous","[email protected]"); FtpWebResponse response = (FtpWebResponse)request.GetResponse();
Stream responseStream = response.GetResponseStream();
StreamReader reader = new StreamReader(responseStream);
Console.WriteLine(reader.ReadToEnd()); Console.WriteLine("Download Complete, status {0}", response.StatusDescription);
reader.Close();
response.Close();
}
}
}
转自MSDN,可以参考下
using System.IO;
using System.Net;
using System.Text;namespace Examples.System.Net
{
public class WebRequestGetExample
{
public static void Main ()
{
// Get the object used to communicate with the server.
FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://www.contoso.com/test.htm");
request.Method = WebRequestMethods.Ftp.UploadFile; // This example assumes the FTP site uses anonymous logon.
request.Credentials = new NetworkCredential ("anonymous","[email protected]");
// Copy the contents of the file to the request stream.
StreamReader sourceStream = new StreamReader("testfile.txt");
byte [] fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
sourceStream.Close();
request.ContentLength = fileContents.Length; Stream requestStream = request.GetRequestStream();
requestStream.Write(fileContents, 0, fileContents.Length);
requestStream.Close(); FtpWebResponse response = (FtpWebResponse)request.GetResponse();
Console.WriteLine("Upload File Complete, status {0}", response.StatusDescription);
response.Close();
}
}
}
}
C#中有专门的FTP封装类,用于上传下载,不算太难。代码也跟楼上的差不多,压缩与解压一切正常。
这个应该就是你要的
http://download.csdn.net/source/791364
速度快,扩展性良好,想怎么做就怎么做
教育网内的服务端和客户端传 单线程传速度都能超过1M/S 传的文件1G左右主要解决断点重传
以及大文件传输 分段保存到硬盘
毕竟内存也是有限的 而且传输中间断了 下次再传也不用从头开始