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

I had created a file with "a+" mode.

I want to write data into that file as
NU2947;03/09/2004;
NU2947;03/09/2004;
F50359;03/06/2004;

but I am getting
F50359;03/06/2004;
NU2947;03/09/2004;

into that file.

Can anyone help me out to write duplicate data in a file.
Also let me know that how can I correct the sequence/order of input data.

Thanks in advance.
Posted
Updated 13-May-10 0:45am
v3
Comments
OriginalGriff 5-May-10 5:34am    
Please provide a code sample - we cannot read minds!

The answer is obvious. Your code, the code you didn't show us, is writing the data in the wrong order. If you write it in the right order, it will appear in the file, in the right order.
 
Share this answer
 
Without seing your code, it is difficult to give an answer. However, if you have to be able to insert a line at a specific location in your file, forget about it. You can only append information at the end of the file. So, if you want to do something like that, the best way is to load everything in memory, sort it in memory and then write the full file once again.
 
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