Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the shortest way to get the string content of a HttpPostedFile in C#

I have an HttpPostedFile object and just need to extract the content of the posted file.

I found this link but that's a very long process to just obtain a string with the content.

Is there any shorter way? (Preferably, a one line instruction.)

like image 482
yorch Avatar asked Apr 27 '12 03:04

yorch


1 Answers

var str = new StreamReader(postedFile.InputStream).ReadToEnd();

StreamReader.ReadToEnd

like image 60
Leniel Maccaferri Avatar answered Nov 01 '22 09:11

Leniel Maccaferri