Click here to Skip to main content
15,885,757 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
In my program i am fetching the data/code from the text file and the same data to be used in the program
Posted

The easiset is:

string[] str = File.ReadAllLines("filepath");


Look at http://msdn.microsoft.com/en-us/library/s2tte0y1.aspx[^]
 
Share this answer
 
Comments
Lakamraju Raghuram 13-Apr-12 1:28am    
you are too generous.
Clifford Nelson 13-Apr-12 1:49am    
If you do not know where to start, it is very difficult to find the stuff when googling. Then you have to go through all the results and try to figure out what to use. I could have just pointed to a page. In the future, just give them a pointer to a good article. I may have been too generious, but he will learn
ravithejag 13-Apr-12 6:04am    
thanks clifford
Your subject is having more suitable information than your message. In fact message is garbage.

And for the task you mentioned in the subject - "Google it" before knocking here
 
Share this answer
 
I am fetching the data using

C#
StreamReader read = new StreamReader(@"//text file path");
 string line = read.ReadLine(); //it reads just one line from the file

if more than one line is present in the text file then use this
C#
string line = read.ReadToEnd();


if i want to use more than one lines from the file i am using the split function and then storing it into an array
C#
string[] datalines = line.Split(new char[] { '\n' });
 
Share this answer
 
v2
Comments
BillW33 21-Jun-12 14:35pm    
You should not post a comment to a solution or an addition to your question as a "Solution". Either add a comment to a previous solution by pressing the "Have a Question or Comment?" button or update your question by using the "Improve question" button.

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