我尝试过几次,但输出没有正确 [英] i tried several times but output is not coming correctly
问题描述
我想用c#将html文件显示到asp.net。
页面加载我的代码如下
string file = Server.MapPath( < span class =code-string> RM.html);
StreamReader sr;
FileInfo fi = new FileInfo(file);
string input = < pre> 跨度>;
if (File.Exists(file))
{
sr = File.OpenText(file);
input + = Server.HtmlEncode(sr.ReadToEnd());
sr.Close();
}
输入+ = < / pre>;
div1.InnerHtml =输入;
RM.html文件内容如下
发动机 - 房间资源管理。
推进装置和辅助机械。
电气,电子和控制系统。
我执行上面的代码输出如下
当我正确的RM.html文件并用记事本打开
记事本内容显示在输出。
但我想要正确的输出如下(Rm.Html)文件内容。
发动机室资源管理。
推进装置和辅助机械。
电气,电子和控制系统。
请从上面的代码帮助我,我犯了什么错误。
change
输入+ = S. erver.HtmlEncode(sr.ReadToEnd());
to
input + = sr.ReadToEnd( );
I want to display html file into asp.net using c#.
in page load My code as follows
string file = Server.MapPath("RM.html");
StreamReader sr;
FileInfo fi = new FileInfo(file);
string input = "<pre>";
if (File.Exists(file))
{
sr = File.OpenText(file);
input += Server.HtmlEncode(sr.ReadToEnd());
sr.Close();
}
input += "</pre>";
div1.InnerHtml = input;
RM.html file content as follows
Engine-room resource management.
Propulsion plant and auxiliary machinery.
Electrical, Electronic and Control systems.
When i execute the above code output as follows
when i right the RM.html file and open with notepad
That notepad content is showing in the output.
But i want correct output as follows (Rm.Html) file content.
Engine-room resource management.
Propulsion plant and auxiliary machinery.
Electrical, Electronic and Control systems.
please help me from my above code what is the mistake i made.
change
input += Server.HtmlEncode(sr.ReadToEnd());
to
input += sr.ReadToEnd();
这篇关于我尝试过几次,但输出没有正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!