Hi Developers,
I have one text file that contains data in a below format
00123456^USA^23:00:01^999^Peter
00646365^England^10:00:04^785^Samuel
8r885777^Australia^12:01:32^123^Romansh
Thanks in Advance
Hi Developers,
I have one text file that contains data in a below format
00123456^USA^23:00:01^999^Peter
00646365^England^10:00:04^785^Samuel
8r885777^Australia^12:01:32^123^Romansh
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Honey22 reputationPosted Jul 16, 2010, 4:34 AM EDT
Try this..
//declaring streamreader to read text file
StreamReader objReader = new StreamReader(filepath);
string sLine = "";
int i = 1;
//checking if the text file is empty or not
while (sLine != null)
{
//reading the line from text file and stored into a string variable
sLine = objReader.ReadLine();
//checking the line stored string varible is empty or not if it it not empty storing the value into dropdownlist
if (sLine != null)
{
//data will be available in the string array named as "s"
string[] s = sLine.Split('^');
//insert statement of data base
}
}
objReader.Close();