Cannot implicitly convert type 'System.Web.HttpPostedFile' to 'System.Web.HttpPostedFileBase'
来源:互联网 发布:福田电动三轮车淘宝 编辑:程序博客网 时间:2024/05/22 17:30
http://stackoverflow.com/questions/3071902/cannot-implicitly-convert-type-system-web-httppostedfile-to-system-web-httppo
A quick peek at Reflector indicates that HttpPostedFileWrapper
inherits from HttpPostedFileBase
and accepts an HttpPostedFile
in the constructor:
foreach (string inputTagName in HttpContext.Current.Request.Files){ HttpPostedFileBase filebase = new HttpPostedFileWrapper(HttpContext.Current.Request.Files[inputTagName]); if (filebase.ContentLength > 0) { //...
TheVillageIdiot brings up a great point about the better looping construct, and it will work for you if you're scope exposes the Request
property of the current HTTP context (e.g. on a Page
, but not in Global.asax
):
foreach (HttpPostedFile file in Request.Files){ HttpPostedFileBase filebase = new HttpPostedFileWrapper(file); // ..
If you have LINQ available, you could use that as well:
var files = Request.Files.Cast<HttpPostedFile>() .Select(file => new HttpPostedFileWrapper(file)) .Where(file => file.ContentLength > 0 && file.ContentType.StartsWith("image/"));foreach (var file in files){ SaveNonAutoExtractedThumbnails(doc, file);}
0 0
- Cannot implicitly convert type 'System.Web.HttpPostedFile' to 'System.Web.HttpPostedFileBase'
- cannot implicitly convert type System.DateTime? to System.DateTime.
- Cannot implicitly convert type 'System.Collections.ArrayList' to 'object[]' ;System.Security.SecurityException: Requested regist
- Cannot convert type ‘ASP.login_aspx’ to ‘System.Web.UI.WebControls.Login’的解决方法
- 发布网站时CS0030: Cannot convert type 'ASP.login_aspx' to 'System.Web.UI.WebControls.Login'
- Cannot convert type 'ASP.login_aspx' to 'System.Web.UI.WebControls.Login'(无法将类型'ASP.login_aspx' 转换为'System.Web.UI.WebControls.Lo
- system.web.extensions TYPE错误
- Unable to cast object of type 'System.Web.HttpApplication' to type 'Microsoft.Practices.CompositeWeb
- System.Web
- using System.Web.Mail to send email
- 错误:cannot convert 'QString' to 'const char*' for argument '1' to 'int system(const char*)'
- Web.config中的system.web system.webServer
- Failed to convert value of type 'java.lang.String' to required type 'org.springframework.web.multipa
- System.Security.SecurityException: Request for the permission of type 'System.Web.AspNetHostingPermi
- 报错:System.InvalidOperationException Could not locate Razor Host Factory type: System.Web.Mvc.MvcWebR
- System.Web.Mail
- System.Web.SessionState
- System.Web.Caching.Cache
- 幕人网门窗幕墙论坛介绍
- hdu1180诡异的楼梯(广搜)
- Shell scriptp
- ACM小技巧
- 使用c3p0数据库连接池时出现com.mchange.v2.resourcepool.TimeoutException
- Cannot implicitly convert type 'System.Web.HttpPostedFile' to 'System.Web.HttpPostedFileBase'
- 珍爱收益,远离点融
- CocoStudio sample讲解 SampleChangeEquip 换装系统
- 黑马程序员-内存管理基础知识
- Android—Bitmap和Drawable
- SpringMVC个人笔记1
- Linux删除文件夹命令
- NEON在Android中的使用举例
- 双链表的建立与实现