Skip to content

C# code to read text file and store it in database.

Leonard Simon

Asked Jun 8, 2015, 6:12 AM EDT1 answer
Share
LinkedInX
I need C# code to read a text file. I'm creating a desktop application.

the text will be like this "[email protected]"
 
I need to save the file in database as
 
Name -> name
age    -> 25
phone->9856584759 
 
read line by line and save in the database.
 
Can anyone help me! 
 
consider all data is fixed number of characters/// for eg - name = first 4 characters 

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    SQL
                string FullText = "[email protected]";
                string Name, Age, Email, phoneNo;
                Name = FullText.Substring(0, 4);
                Age = FullText.Substring(4, 2);
                Email = FullText.Substring(6, 14);
                phoneNo = FullText.Substring(20, 11);
    
                Console.WriteLine("Name is {0} and Age {1} Email-Address {2} Contact No {3} ", Name, Age, Email, phoneNo);
    0