iOS Question Different behavior of File.ReadBytes (Dir, fileName)

Star-Dust

Expert
Licensed User
Longtime User
After weeks of working on a server I have problems that I attributed to ASyncStreams in the first phase.
But after a lot of testing and a lot of time I realized that the problem is on file.ReadBytes.

In debug mode, I read a file from dirAsstes (or from DitTemp) and it tells me the right size and loads it correctly.
But in release mode the file is bigger looking at it with File.Size (Dir, fileName) and in fact with file.ReadBytes it produces me a bigger array.

Why?
At first glance it would appear to add 6220 bytes at the end, but in reality it doesn't.

I am attaching an example that you can try. This I get from the Debug Logs:
Application_Start
Application_Active
Logo.png Size :76361

In release instead
Logo.png Size :82851

PS. It happens to me with PNG or JPG files. It does not happen when reading text files. And I put in DirAssets a file with extension .bin and it didn't give me this problem.
 

Attachments

  • ReadBytesError.zip
    76.9 KB · Views: 206
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
I solved it by compressing everything into a zip file and on launching the app I unzip to the DirTEMP folder.
This ensures that the files are read correctly.
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
It seems to be an old problem. Here I take note and continue with the solution indicated

 
Upvote 0
Top