Roland Posted October 3, 2016 Share Posted October 3, 2016 When writing to a file using FileSystem/Stream the content is not flushed to disk directly when the filehandler is set to nil. A close() or flush() function would be a solution to this. Here is my test -- FILE IO TEST local fw = FileSystem:WriteFile("test.bin") if fw ~= nil then System:Print( "*** FILE WRITE" ) fw:WriteInt(12345) fw = nil end local fr = FileSystem:ReadFile("test.bin") if fr ~= nil then local value = fr:ReadInt() System:Print("*** FILE READ = " .. value ) fr = nil end The result ===================================================== *** FILE WRITE *** FILE READ = 0 ===================================================== After the program has finished the content is 12345 as it should be. Here is the same with LUA io-operations which works --- FILE IO TEST local fw = io.open("test.bin", "wb") if fw ~= nil then System:Print( "*** FILE WRITE" ) fw:write(12345) fw:close() end local fr = io.open("test.bin", "rb") if fr ~= nil then local value = fr:read() System:Print("*** FILE READ = " .. value ) fr:close() end and the correct result ===================================================== *** FILE WRITE *** FILE READ = 12345 ===================================================== Roland Strålberg Website: https://rstralberg.com Link to comment Share on other sites More sharing options...
Rick Posted October 3, 2016 Share Posted October 3, 2016 Does calling :Release() on fw work? 1 Link to comment Share on other sites More sharing options...
Roland Posted October 3, 2016 Author Share Posted October 3, 2016 Does calling :Release() on fw work? Yes that worked. Thanks .. how in the heck could I forget about Release I'm soon in that age when it could be explained by dementia. Guess this is kind of solved then 2 Roland Strålberg Website: https://rstralberg.com Link to comment Share on other sites More sharing options...
Recommended Posts