Introduction
I will explain How to read text file showing the TextBox in Asp.Net
Description
Examples of open files using ASP.NET
and Text Files read display on the site using ReadLine to read each line.
Example
C#
I will explain How to read text file showing the TextBox in Asp.Net
Description
Examples of open files using ASP.NET
and Text Files read display on the site using ReadLine to read each line.
Example
<%@
page language="C#" autoeventwireup="true" codefile="How-to-read-text-file-showing-TextBox-c.aspx.cs"
inherits="How_to_read_text_file_showing_TextBox_c"
%>
<!DOCTYPE
html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml">
<head
runat="server">
<title>How to
read text file showing the TextBox</title>
</head>
<body>
<form id="form1"
runat="server">
<div>
<asp:textbox id="TextBox1" runat="server" height="213px" textmode="MultiLine" width="450px"></asp:textbox>
</div>
</form>
</body>
</html>
|
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
public partial
class How_to_read_text_file_showing_TextBox_c : System.Web.UI.Page
{
protected void Page_Load(object
sender, EventArgs e)
{
string FileName = null; StreamReader fp = null;
FileName =
"setup.log"; try
{
fp = File.OpenText(Server.MapPath(FileName)); TextBox1.Text = fp.ReadToEnd(); fp.Close();
}
catch (Exception err)
{
TextBox1.Text = "File Read Failed. Reason is as follows " + err.ToString();
}
finally
{
}
}
}
|
0 comments :
Post a Comment