Skip to main content
Known Participant
September 17, 2018
Question

load and save files for mobile and desktop

  • September 17, 2018
  • 1 reply
  • 263 views

I saved a file in a similar way(File.desktopDirectory.resolvePath("test.txt")) because I couldn't figure out how save a file in my swf folder that gets uploaded to to the android.  Now I tried to access the file this way but i get

Error: Error #2030: End of file was encountered. at flash.filesystem::FileStream/readUTF()

var myFile:File = File.desktopDirectory.resolvePath("test.txt");

var fileStream = new FileStream();

fileStream.open(myFile, FileMode.READ);

//the file is not gone

var fileText:String = fileStream.readUTF();

fileStream.close();

trace(fileText)

I have used   URLRequest = new URLRequest("test.txt")  but I dont know how to get to the document folder that way and I dont know if a path would work for android and computer

maybe sharedObject is the better way to go for storing data but I am more comfortable using xml files

I have spent hours on this that is just the latest attempt

This topic has been closed for replies.

1 reply

Robert Mc Dowell
Legend
September 17, 2018

this error means that test.txt has no bytes into it. so maybe the problem comes before you save it.

Known Participant
September 17, 2018

The other file was UTFbytes not UTF I switched both to UTF and it worked.  I first tried switching them to UTFBytes and it didnt work.  I don't really know the difference but it is all good.  Your advice helped and a fresh start in the AM

much Thanks