[webmethod]
public byte[] getFile(string fileName)
    {
}
客户端建立内存流再保存文件,如果文件很大就会出错如何能实现读取一点文件保存,再读取再保存?

解决方案 »

  1.   

      这个没有太好的办法   这个和IIS及上传的性能有关   
        
      如果对于较大的文件建议采用FTP软件上传   
        
      不要通过网页上传       
      

  2.   

    别用WebService传文件,其个人认为极限是2M
    64位的来回转换会使其流量是正常传输的4倍
      

  3.   

    建议分段上传。
    bool UploadFile(string fileName, byte[] fileContent, int contentLength, bool resume)
    {
                FileStream fs = null;
                if (resume)
                {
                    fs = new FileStream(fileName, FileMode.Open, FileAccess.Write, FileShare.None);
                    fs.Position = fs.Length;
                    fs.Write(fileContent, 0, contentLength);
                    fs.Flush();
                    fs.Close();
                    fs.Dispose();
                }
                else
                {
                    fs = new FileStream(fileName, FileMode.CreateNew, FileAccess.Write, FileShare.None);
                    fs.Write(fileContent, 0, contentLength);
                    fs.Flush();
                    fs.Close();
                    fs.Dispose();
                }
                return true;
    }
      

  4.   

    通过压缩实现文件流传输
    http://www.cnblogs.com/support/archive/2006/09/29/518430.aspx
    http://www.cnblogs.com/gxh973121/articles/331600.html
      

  5.   

    还是用FTP好了~这样不容易受限制~