Unable to cast object of type 'System.Web.HttpInputStream' to type 'System.IO.FileStream' MVC 3

后端 未结 5 820
無奈伤痛
無奈伤痛 2021-02-19 06:37

I have met an issue regarding the casting type from HttpInputStream to FileStream.

How I did ?

I have a HttpPostedFileBase object and I want to have

5条回答
  •  梦如初夏
    2021-02-19 07:01

    public byte[] LoadUploadedFile(HttpPostedFileBase uploadedFile)
    {
        var buf = new byte[uploadedFile.InputStream.Length];
        uploadedFile.InputStream.Read(buf, 0, (int)uploadedFile.InputStream.Length);
        return buf;
    }
    

提交回复
热议问题