Click here to Skip to main content
14,734,709 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How to read the contents from .txt file or .ini file in web application.i want to read the each name from a name list in the text file.

Open the file and read it.

using(StreamReader stream = new StreamReader("filename"))
    string line = null;
    while( (line = stream.ReadLine()) != null)

string fileText = System.IO.File.ReadAllText("filename")

But ini files are a different matter. Unless you are accessing settings in a legacy app, DON'T USE INI files, instead use your web.config file.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900