I have this method which does not build, it errors with the message:
Cannot implicitly convert type ‘
System.Web.HttpPostedFile‘ to ‘System.Web.HttpPostedFileBase‘
I really need this to be of type HttpPostedFileBase instead of HttpPostedFile, I have tried boxing and it does not work:
foreach (string inputTagName in HttpContext.Current.Request.Files)
{
HttpPostedFileBase filebase =HttpContext.Current.Request.Files[inputTagName];
if (filebase.ContentLength > 0)
{
if (filebase.ContentType.Contains("image/"))
{
SaveNonAutoExtractedThumbnails(doc, filebase);
}
}
}
A quick peek at Reflector indicates that
HttpPostedFileWrapperinherits fromHttpPostedFileBaseand accepts anHttpPostedFilein the constructor:TheVillageIdiot brings up a great point about the better looping construct, and it will work for you if you’re scope exposes the
Requestproperty of the current HTTP context (e.g. on aPage, but not inGlobal.asax):If you have LINQ available, you could use that as well: