tags:

views:

184

answers:

2

How can I install a text file as part of a MonoTouch app? I know how to create, write to, and read from a text file in the app's Documents folder, but I want to install a text file previously created (outside of the app). I added a text file to the MonoTouch project, and marked it as "Content", but after I deploy to the simulator, I do not see my file in any of the app's folders.

A: 

Are you checking the right place? It will be in the app bundle which is typically at:

~/Library/Application Support/iPhone Simulator/User/Applications/{guid}/

Right click on your app name and select "show package contents".

Chris S
A: 

I've created new solution, created Documents folder and put my file inside Documents. In file properties i've setted "Build action: Content" and "Copy to output directory: Always copy"

In program, i tried to read file in this way

var documents = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
using (var o = File.OpenText(Path.Combine(documents, "book.txt"))) o.ReadLine();

but i've follow exception Unhandled Exception: System.IO.IsolatedStorage.IsolatedStorageException: Could not find file "/Users/myuser/Library/Application Support/iPhone Simulator/3.2/Applications/{guid}/Documents/book.txt"

what is the problem?

thanks.

Premier