Jump to content




Refresh all files in computer ?



  • You cannot reply to this topic
3 replies to this topic

#1 mrhappy5354

  • New Members
  • 2 posts

Posted 17 January 2015 - 06:35 AM

When I simply open and write in a text file:
u = fs.open("Hello", "w")
u.write("Hello")

and then I edit the file nothing is written in it, the text will only appear after I reboot the computer...

So is there a fix, because this is really annoying...

Thanks

#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 17 January 2015 - 10:14 AM

You're supposed to close file handles after you're done using them. Throw this after the write call:

u.close()

That will close the file handle and write your changes to the actual file.

#3 ElvishJerricco

  • Members
  • 803 posts

Posted 17 January 2015 - 11:51 AM

Also, flushing writes unwritten data to disk. Closing says "I'm done, I have no more to write. Put all my changes on disk and clean up now." This is required. But flushing just puts the changes on disk, without doing the closing, so that you can continue to write to the file after flushing.

u.writeLine("Hello")
u.flush()
u.writeLine("Hello again")

The resulting file will only have the "Hello" line, because that line was flushed, and the second line was not, since the handle was never closed or flushed after its writeLine call.

#4 mrhappy5354

  • New Members
  • 2 posts

Posted 17 January 2015 - 07:30 PM

Thanks a lot for the quick respond !





3 user(s) are reading this topic

0 members, 3 guests, 0 anonymous users