0
如何在运行时设置HttpPostedFileBase ContentType值?如何在运行时设置HttpPostedFileBase ContentType值
HttpPostedFileBase upl=null;
string path="/exelFile/book1.xlsx";
//-----Set Name Runtime
var Name="FileName.xlsx";
//-----Set Type Runtime
var type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
byte[] bytes =System.IO.File.ReadAllBytes(Server.MapPath(Path));
upl = (HttpPostedFileBase)new MemoryPostedFile(bytes, Name);
//=====>how set type
upl.ContentType
//==============
'HttpPostedFileBase'用于从浏览器上传文件。它的'ContentType'是只读的(它只能吸气)。什么是“MemoryPostedFile”?你想在这里做什么? –
我想MemoryPostedFile到这个HttpPostedFileBase。有没有办法? –
你还没有说过'MemoryPostedFile'是什么。但这样做没有意义。你想实现什么? –