I am building a Windows Phone game using C#/XNA. In the game, I need to be able to read some data from IsolatedStorage. For this, I create an IsolatedStorageFileStream and then call the Read function. The msdn documentation for IsolatedStorageFileStream.Read states the following:
The buffer parameter can be an instance of the Buffer class, or an array of one of the following types: Byte, SByte, Char, Int16, Int32, Int64, UInt16, UInt32, UInt64, Single, or Double.
However, there is only one overload for the Read function, and it takes an array of bytes, not integers or any other type. I realize that the easy workaround is to read the data into a block of bytes, and then use the BitConverter.ToInt32 function in a loop to get the data I want. However, I want to be able to read a block of integers directly from the file into an array of integers, without spending extra intermediate memory, if possible. Any ideas?
You can use Streams to work with the isolated storage. They make access to isolated storage much easier. This way you can avoid the low level access with bytes and buffers.
A good start:
http://create.msdn.com/en-US/education/quickstarts/Isolated_Storage
Some real good articles about isolated storage (and Windows Phone 7 development):
http://www.windowsphonegeek.com/tips/all-about-wp7-isolated-storage–intro-to-isolated-storage