# Read custom content in MONO-GAME in a cross-platform way

using Mono-Game,

• i have some custom content files in some binary format (not .xnb)

• in run-time i need to read the content of those files.

• i prefer to get a stream, but if something will give me a filled byte[] or something, that's also fine..

• this must be cross-platform as much as possible and work on PC \ Mobile \ consoles \ web \ what-ever-mono-game-offers

;

my efforts so far :

• subclassing ContentManager, and overriding OpenStream(string assetName) did not help - it expects the file i give it to end with .xnb

• renaming all files to ".xnb" just for this is not possible for me, because some other proccess reads thease files and expects them the way they are

• TitleContainer.OpenStream() seems to read files from the file system, but im not sure how they will be packed when building for mobile devices for example.

(i know that in unity: for android, content is simply copied to a folder on the device, but on iphone all content is packed to a binary package.. so reading from the file-system will not work)

(i dont have an iphone\ipad to test this on)

• the simple "File.ReadAllBytes()" is no good for the same reason

;

My questions are :

1. am i right about TitleContainer's cross-platform limitation ?
2. what can i do ?

thanks.

• what format are those files in ? – dimitris93 May 5 '15 at 16:55
• different formats, some are .png .mp3 .txt , some are unique binary formats – Levan May 5 '15 at 17:03
• @nikoliazekter The question is about using custom content in a game made with Monogame. I don't think your comment is relative here – dimitris93 May 5 '15 at 17:37

TitleContainer.OpenStream() allows you to read from the filesystem. If your package includes the files, I would expect the method to be able to read it. After all, as you state, Unity would copy the content to a folder as well. So if you set the properties of the files to be included in your build step, you should be able to read it.