如何使用Fileupload读取文件的内容 [英] how to read the content of the file using Fileupload

查看:109
本文介绍了如何使用Fileupload读取文件的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用Fileupload读取文件的内容.

Is it possible to read the content of a file using Fileupload.

例如,我要将XML文件保存在Database中,用户使用Fileupload搜索该文件,然后单击一个按钮以将文件内容保存在Database中.

For example I want to save the XML file in Database , a user search the file using Fileupload and then click a button to save the content of the file in Database.

我尝试了这个,但是没有用

I tried this one but doesn't work

string s=Fileuploder1.Filecontent.tostring();

但没有成功,你有什么主意吗?

but no success,Do you have any idea?

推荐答案

string inputContent;
using (StreamReader inputStreamReader = new StreamReader(InputFileUpload.PostedFile.InputStream))
{
    inputContent = inputStreamReader.ReadToEnd();
}

这篇关于如何使用Fileupload读取文件的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆