.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> Javascript >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Reading files dynamically in C#.net

Posted By:Athira Sreejith       Posted Date: December 31, 2008    Points: 10    Category: Javascript    URL: http://www.dotnetspark.com  
 

The following C# sample code shows how to read files dynamically.


using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
readFile();
}

private void readFile()
{
string Filename = "NextTextfile.txt";
string FILENAME = Server.MapPath(Filename);
StreamReader streamReader;
streamReader = File.OpenText(FILENAME);
string content = streamReader.ReadToEnd();
lblMessage.Text = content;
objStreamReader.Close();
}
}

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend