First line of a text file being overwritten with g

Results 1 to 2 of 2

Thread: First line of a text file being overwritten with g

  1. #1
    Join Date
    Dec 1969

    Default First line of a text file being overwritten with g

    I&#039;m using a text file to store a list separated by commas, loading it as a text stream, splitting it into an array, and doing a bubble sort, then resaving the joined array, using the following code. It worked fine for some time, but now it seems to be overwriting the first few characters of the text file with what looks like gibberish to me - it actually overwrites with this : ÈM@ÈM@<BR>It appears that the overwriting is happening while saveing the file, because the joined array before saving is unharmed, and is only harmed when the file is loaded again as a textstream.<BR><BR>What is going on ?<BR>The following code is only the part that is saving the file.<BR>Please help.<BR><BR><BR>savedata= join(q, ",")<BR><BR>Set fso = Server.CreateObject("Scripting.FileSystemObject")< BR><BR>set file = fso.CreateTextFile(server.mappath("popular.dat"), true)<BR><BR><BR><BR>file.write savedata<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default Unicode?

    It looks to me like you are writing the file and then reading it as ASCII. Or vice versa.<BR><BR>Show *all* the code that reads and writes it?<BR><BR>Oh, yes... <BR><BR>And do<BR><BR>Response.Write "DEBUG: savedata is " & savedata & "&#060;HR&#062;"<BR><BR>just to be sure you have what you thing you have.<BR><BR>(And shouldn&#039;t you do file.writeline, to ensure you can do readline when you read the file?)<BR><BR>

Posting Permissions

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