简单代码:

    /*服务器端接收写入 可以实现断点续传*/
    public  string  ConnectUpload(string newfilename,string filepath,byte[] fileByte)  
    {
    try{
          string path = adpath + newfilename;                     
          FileStream fs = new FileStream(path, FileMode.Append);
          BinaryWriter w = new BinaryWriter(fs);                     
          fs.Position = fs.Length;                     
          fs.Write(fileByte, 0, fileByte.Length);                     
          w.Close();
          fs.Close();
          return "1";
       }
      catch{
        return "-1";   
       }
    }

    /*客户端循环添加*/
    int count = 0;
    int bufferSize = 256;        
    byte[] buffer = new byte[bufferSize];
    while (count < FileUpload1.FileContent.Length)        
    {            
        int bytes = FileUpload1.PostedFile.InputStream.Read(buffer, 0, bufferSize);            
        string result = ConnectUpload(newfilename, filepath, buffer);            
        if (result != "1") //报错            
        {        
             break;
        }    
   }

  

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-04-08
  • 2021-06-11
  • 2022-12-23
  • 2022-12-23
  • 2021-12-14
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-29
  • 2021-11-28
  • 2022-12-23
  • 2021-08-15
相关资源
相似解决方案