Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Why can't I write to iOS Documents folder?

$
0
0

I finally got access to a real iPad to test my app today (I started the process on July 18, the day Apple took down the site). This is my 1st app. After a day of debugging, I reduced the problem to a snippet of code. I assume I'm missing something simple.

var directories = Directory.EnumerateDirectories("./");

foreach (var directory in directories) {

    Console.WriteLine(directory);}

DirectoryInfo di = new DirectoryInfo (@"./Documents");

foreach (FileInfo fi in di.GetFiles("*.*"))

   Console.WriteLine (fi.Name);

string[] getText = File.ReadAllLines ("./Documents/text.txt");

for (int i = 0; i < getText.Length; i++)

   Console.WriteLine(getText[i]);

try

{

   File.WriteAllLines("./Documents/text.txt", getText);

}

catch(System.IO.IOException)

{

    Console.WriteLine("IOException");

}

catch(System.ArithmeticException)
{

    Console.WriteLine("Arithmetic");
}

catch

{

    Console.WriteLine ("???? Error");
}




console output:

./Documents
./MainStoryboard.storyboardc
./Settings.bundle
./_CodeSignature
ecalc2.ini
text.txt
ABCD
EFGH
???? Error


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>