yorch
yorch

Reputation: 7318

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.)

Upvotes: 22

Views: 13767

Answers (1)

Leniel Maccaferri
Leniel Maccaferri

Reputation: 102408

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

StreamReader.ReadToEnd

Upvotes: 45

Related Questions