Click here to Skip to main content
14,643,812 members
Rate this:
Please Sign up or sign in to vote.
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

Rate this:
Please Sign up or sign in to vote.

Solution 1

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
StreamWriter writer=new StreamWriter(@"filepath")
   

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100