This project is read-only.

Loading from a txt file + fonts.

Feb 9, 2010 at 1:00 PM

I'm just wondering how would i go about loading from a txt file that is in Content/Maps.

Also how do i go about adding a font? I have atried for ages, i coped the BeckerBlack that comes with the snake sample and it still doesn't work. I did also use the AddFont.




(also texture2d.GetPixel() gets it from the image source, which is all well and good, but if you rezised the image then it goes off the normal sized instead of the smaller sized.

Feb 9, 2010 at 1:20 PM

Well i worked out how to open a file by using

StreamReader mapFile = new StreamReader(SilverArcade.SilverSprite.IO.File.OpenRead("Content/Maps/Map" + mapNumber.ToString() + ".txt"));

but i get this error

Operation not permitted on IsolatedStorageFileStream.


Any 2 ways around it?

Feb 9, 2010 at 2:28 PM

Use the Isolated Storage for things like saving user settings, save games etc., e.g.:



 IsolatedStorageFileStream zipStream = null;
            using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication())
                if (store.FileExists(zipFileName))
                    zipStream = store.OpenFile(zipFileName, FileMode.Open);

IsolatedStorageFileStream fStream = null;

using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication())


if (store.FileExists(FileName))


fStream = store.OpenFile(FileName, FileMode.Open);





To get a stream from my game's actual content, I use the following:


StreamResourceInfo info = Application.GetResourceStream(FileName);

Stream fStream = info.Stream;