read file content in c# asp.net

    protected void Page_Load(object sender, EventArgs e)
    {
        ReadTextFile();
    }

    void ReadTextFile()
    {
        string inputString;
        using (StreamReader streamReader = File.OpenText(Server.MapPath("~") + @"\test.txt"))
        {
            inputString = streamReader.ReadLine();
            while (inputString != null)
            {
                Label1.Text += inputString + "
";
                inputString = streamReader.ReadLine();
            }
        }
    }

Comments

Popular posts from this blog

like php