Writing to the beginning of a file

NickOlsen
05-12-2004, 12:00 AM
I have written an order form program and when an order is recorded, it has to identifying numbers, a customer reference number and a record number. I have a seperate form where you can enter one of the two numbers and it will give you the corresponding number. It's data source is a .txt file that contains all the customer reference numbers and the record numbers. I have it set now that whenever you save a number, it appends the two numbers to my .txt document. This obviously puts the next text at the bottom of the .txt document. Is there anyway to append text to the top of the document instead of the bottom. For example:

'**********original txt document ********
12
1678
13
1679

**********text document after appending*******
12
1678
13
1679
14
1680

**********text document that I want*******
14
1680
12
1678
13
1379

malloc
05-12-2004, 03:29 AM
The only way I can think of is to write the two lines to a new file, that way they are at the beginning and then write all the lines from the original file to the new file.
Kill the original file and rename the new file.

MKoslof
05-12-2004, 08:37 AM
Yes, you would basically have to print over top of the existing file(basically copying over it when you have new data). You could do this in .Net via the TextWriter or StreamWriter classes.

NickOlsen
05-12-2004, 10:21 AM
Alright, that what I thought but I was hoping there was maybe something I was overlooking. Thanks!

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum