在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
c#服务端接收客户端发送上传多个文件的请求,需要把每个文件流单独取出来,直接上代码
HttpContext context = HttpContext.Current; for (int i = 0; i < context.Request.Files.Count; i++) { try { HttpPostedFile aFile = context.Request.Files[i]; Stream mystream = aFile.InputStream; StreamReader reader = new StreamReader(mystream); string xml = " "; StringBuilder strXML = new StringBuilder(); while (reader.Peek() >= 0) { string line = reader.ReadLine().Trim();//直接读取一行 if (line == null) return null; if (line == String.Empty) continue; if (line.StartsWith("<")) { xml = line.Trim(); strXML.Append(xml); } } String xmlData = reader.ReadToEnd(); byte[] bytes = System.Text.Encoding.UTF8.GetBytes(strXML.ToString()); listContentByte.Add(bytes); Console.WriteLine(); } catch { } } |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论