locked
How to append data in the begining of a file? RRS feed

  • Question

  • Hi,

    How to append data in the begining of a file.

    I want to enter some data in a very large file.To do this i am leaving some blank lines in the begining of the file, because i don't want to move down the data in a file. But while inserting data in the begining, it overlaps the current data.

     

    Wednesday, December 12, 2007 3:29 PM

Answers

  • Hi... unless you have direct access to disk drive (beyond windows services for this - hard to do let me say) you cannot. You have to fully rewrite your file every time you append something at the very beginning.

     

    One solution could be filling (from time to time, not always) the begining of the file with lines as you said (this is a fully rewrite of your file), but not with empty lines. Fill every new line as long (with spaces) as you might need them, so you can overwrite the spaces with the new data. Of course, you must control the moment when you have to add new lines. Not so practical, but sort of a solution.

     

    Or, try to use a database solution for this.

     

    What are you trying to accomplish with this?

     

     

     

    Wednesday, December 12, 2007 5:59 PM