做一个文件传送的系统(局域网),SERVER端接收文件,CLIENT端发送文件。
    我想问的是:
        1.C#中关于FTP有没有封装好的东西
        2.采用SOCKET直接将client端的文件名和文件内容发送过去,server端建立一个同名文件写入这样是否可行
        3.就上面的做法,ZIP、RAR文件能否在建立后顺利解压谢谢大家,或者谁有现成的FTP或者只要是文件传送的源能够给小弟看一眼,不胜感谢
E-MAIL:[email protected]

解决方案 »

  1.   

    那这样也就没用到FTP了,如果要用FTP怎么做呢
      

  2.   

    我用过FTP的API,过比较麻烦,而其API用的不好会不安全,
    第二种方法比较方便,但是有局限性,需要C/S结构,
    VB里有正对FTP的控件,C#里没用过,不清楚有没有
      

  3.   

    using System;
    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,可以参考下
      

  4.   

    using System;
    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();
                }
            }
        }
    }
      

  5.   

    我最近在做一个客户端,与FTP交互的,即上传下载。
    C#中有专门的FTP封装类,用于上传下载,不算太难。代码也跟楼上的差不多,压缩与解压一切正常。
      

  6.   

    .net有FTP封装好了的类,你自己去Net命名空间找找吧,MSDN也有示例的
      

  7.   

    用Socket吧,可以完全自己控制.之前写过一个,服务端监听,异步处理各客户端连接请求,压缩传输,服务端解压的.不过是公司项目里面用的,代码就不方便公开了.
      

  8.   

    这个比较麻烦,,如果是简单传几个KB。。还可以用上面方法。如果是几个MB或者几G。必须用要MD5校验。因为会丢失!
      

  9.   

    http://www.csharpwin.com/csharpresource/1135.shtml
    这个应该就是你要的
      

  10.   

    好象是仿飞鸽C井地代码:
    http://download.csdn.net/source/791364
      

  11.   

    就用SOCKET传就可以了,局域网中通信的可靠度还是很高的
      

  12.   

    WebClient 就可以了啊,我在项目中实现了上传下载!
      

  13.   

    自己搭一个FTP Server随便写一个FTP客户端.
      

  14.   

    一直在做这个    用的是方法2
    速度快,扩展性良好,想怎么做就怎么做
    教育网内的服务端和客户端传   单线程传速度都能超过1M/S  传的文件1G左右主要解决断点重传
    以及大文件传输  分段保存到硬盘
    毕竟内存也是有限的  而且传输中间断了    下次再传也不用从头开始