var files = System.Web.HttpContext.Current.Request.Files; files.AllKeys.Select(k => files[k]);
写一个扩展方法,比如:
public static class Extensions { public static List<HttpPostedFile> ToHttpPostedFileList(this HttpFileCollection collection) { if (collection == null) throw new ArgumentNullException("collection"); var httpPostedFileList = new List<HttpPostedFile>(); for (int i = 0; i < collection.Count; i++) { httpPostedFileList.Add(collection[i]); } return httpPostedFileList; } }