借助 .NET 4.0 新增的 Stream.CopyTo (),可以轻松实现“流对流”保存上传文件,示例代码如下:

public ActionResult ProcessUpload(string filename)
{
    using (var inputStream = Request.InputStream)
    {
        using (var flieStream = new FileStream(@"c:\temp\" + filename, FileMode.Create))
        {
            inputStream.CopyTo(flieStream);
        }
    }
    return Json(new { success = true });
}

今天的作业完成!

 

相关文章:

  • 2021-11-22
  • 2021-05-29
  • 2021-12-24
  • 2021-07-07
  • 2021-06-26
  • 2021-12-19
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-23
  • 2021-07-07
  • 2022-12-23
  • 2021-09-20
  • 2022-12-23
相关资源
相似解决方案