Click here to Skip to main content
15,897,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have to read a text file which contains companyIds(approximately 75000).After reading the text file content, i need to get the corresponding company information from the database and write to a output text file(YYYYMMDDhhmmss_out.txt).I tried to read the text file and loaded the companyids into a collection object(LIST<t>).But how to write the company information all at a time into single output file.I tried to write first company info to output file,but when i tried to write the next company info again new output file is getting created (with file name differs in mmsss part) as it should not be.How to write the company information all at a time to a single output file.

Can anyone please help me reg this.

Thanks in Advance.
Posted

1 solution

use datarow to read database content, use streamwriter to write into file.
use foreach loop for multiple records make sure that you keep this line out of the loop
C#
StreamWriter writer=new StreamWriter(@"filepath")
 
Share this answer
 

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