简体   繁体   English

在C#中获取HttpPostedFile的字符串内容的最短方法是什么?

[英]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. 我有一个HttpPostedFile对象,只需要提取已发布文件的内容。

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.) (最好是一行指令。)

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

StreamReader.ReadToEnd

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM