FileUpload to FileStream

前端 未结 4 1880
孤独总比滥情好
孤独总比滥情好 2020-11-30 06:48

I am in process of sending the file along with HttpWebRequest. My file will be from FileUpload UI. Here I need to convert the File Upload to filestream to send the stream al

4条回答
  •  Happy的楠姐
    2020-11-30 07:43

    You can put a FileUpload file directly into a MemoryStream by using FileBytes (simplified answer from Tech Jerk)

    using (MemoryStream ms = new MemoryStream(FileUpload1.FileBytes))
    {
        //do stuff 
    }
    

    Or if you do not need a memoryStream

    byte[] bin = FileUpload1.FileBytes;
    

提交回复
热议问题