Action

怎么构造 HttpPostedFileBase 对象

描述:在实现上传文件的过程中,有时需要自行构造 HttpPostedFileBase 对象。查看这个类型的定义,它是不能被直接实例化的,那就只能通过间接的方法达成这一目的。

解决方案:先取得 HttpPostedFile 对象,然后使用 HttpPostedFileWrapper 对其进行包装。

var hpf_file = System.Web.HttpContext.Current.Request.Files.Get(0);
var hpfb_file = new HttpPostedFileWrapper(hpf_file);

相关文章:

  • 2022-01-01
  • 2022-12-23
  • 2022-12-23
  • 2021-09-29
  • 2021-07-16
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-09-23
  • 2021-11-11
  • 2022-12-23
  • 2022-01-07
  • 2022-12-23
  • 2021-05-29
  • 2021-04-03
相关资源
相似解决方案