Appending to the start of a file - can it be done?

Results 1 to 3 of 3

Thread: Appending to the start of a file - can it be done?

  1. #1
    Join Date
    Dec 1969
    Posts
    7

    Default Appending to the start of a file - can it be done?

    I&#039m trying to make a guestbook [without using a database] and at the moment all the entries are written to a text file. The only propblem is that when the guestbook page reads off that file it does so from top to bottom.<BR><BR>Thus the most recent guestbook entry is at the top of the guestbook page. And I&#039m trying to find a way to get the most recent entry to the top.<BR><BR>The obviously solution is just to append the new entries to the start of the text file - only I don&#039t know how to do it.<BR><BR>Anyone help?<BR><BR>Thanks

  2. #2
    Jim Cruff Guest

    Default RE: Appending to the start of a file - can it be d

    Why don&#039t you continue to append the data to the end of the file but read the file backwards - End of file to Beginning of file.<BR><BR>I have a VB application that does this and I&#039m sure that the same logic can be applied to ASP pages. I haven&#039t tested it in ASP but I&#039m sure it will work.<BR><BR>You will need to setup a DSN for the text file on your IIS server. Then the rest is in the code:<BR><BR>============== VB CODE ==============<BR><BR> Dim db As Database<BR> Dim rs As Recordset<BR> Dim X As Long<BR> <BR> Const LocalEdiFileName = "Edi.txt"<BR> Const EdiPath = "g:Edi\"<BR> <BR> Set db = OpenDatabase(EdiPath, False, False, "Text;")<BR> Set rs = db.OpenRecordset(LocalEdiFileName)<BR><BR> rs.MoveLast<BR> <BR> Do Until rs.BOF<BR> Debug.Print rs!Segment, rs!Element01, rs!Element02<BR> rs.MovePrevious<BR> Loop<BR> <BR> rs.Close<BR> db.Close<BR> Set rs = Nothing<BR> Set db = Nothing<BR> End<BR> <BR>============== VB CODE ==============<BR><BR>Hope this helps

  3. #3
    Join Date
    Dec 1969
    Posts
    13

    Default That was cool :)

    Thanks for a gr8 idea...I just happened to come across this post and really liked the code...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •