There are two types of file access in Windows Phone applications. One is about creating files from within an app that can be read after an application restart. The files are saved in a kind of sandbox that isolates the application specific data from access by another application (hence the name IsolatedStorage). Another way of accessing files is about reading files you ship with an application, such as XML or text files. This is about reading so called “Resources”.

To save user data in the isolated storage, first you have to get a handle on the storage location for the current application. When you got it, you can create a stream that you can use for regular I/O:

IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication();

using (IsolatedStorageFileStream stream = new IsolatedStorageFileStream(@“file.txt”,FileMode.Open,file))\ {\ long length = stream.Length;\ byte[] readbytes = new byte[length];\ stream.Read(readbytes, 0, (int)length);\ }

Using resources works more or less the same, the only difference is that you need to use the static method “Application.GetResourceStream” with a URI to create a “StreamResourceInfo” object.

List<String> RandomStrings = new List<String>();\ String fileContent;

StreamResourceInfo fileres = Application.GetResourceStream(new Uri(“file.txt”, UriKind.Relative));\ using (System.IO.Stream isoFileStream = fileres.Stream)\ {\ using (var fileReader = new System.IO.StreamReader(isoFileStream)) {\ fileContent = fileReader.ReadToEnd();\ }\ }

Be aware that you should probably handle exceptions in a real application.