End of File???

Results 1 to 2 of 2

Thread: End of File???

  1. #1
    Join Date
    Dec 1969

    Default End of File???

    I have a unicode file that I&#039;m opening, changing and writing the changes to a temp file before writing it back over the original.<BR><BR>Here&#039;s the code:<BR><BR>var infile = fs.OpenTextFile(orig,1,false,-1) // read from here<BR>var tempfile = fs.OpenTextFile(temp,2,true,-1) // write to here<BR>.<BR>...processing --&#062; this is where the end of file is searched for and found in wierd places after the first edit<BR>.<BR>infile.Close()<BR>tempfile.Close()<BR >var tempfile = fs.OpenTextFile(temp,1,false,-1) // read from here<BR>var outfile = fs.OpenTextFile(orig,2,true,-1) // and write back<BR>while (!tempfile.AtEndOfStream) // while not at end of temp file<BR>{ var c = tempfile.Read(1) // read one char<BR> outfile.Write(c) // write it back to the original<BR>}<BR>tempfile.Close()<BR>outfile.Close ()<BR>fs.DeleteFile(temp)<BR><BR>This stuff works the first time, but the next time I try to read the original file and make changes to it, the end of file happens somewhere strange. It reads about half of the file, then finds an end of file and I can&#039;t access the entire file. Any suggestions?

  2. #2
    Join Date
    Dec 1969

    Default RE: Guessing....

    Instead of closing the tempfile and outfile I would set them to "Nothing" just to make sure there is nothing left in memory.<BR><BR>an idea.?.?.?

Posting Permissions

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