Creating a file Error

Hi
I am trying to create a text file in the "/mnt/sdcard" folder but i am getting an error

"/mnt/sdcard/ServURL.txt (Permission denied)" and java.io.fileNotFoundException.

Permissions in the Manifest are:

<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.BATTERY_STATS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.USE_SIP" />
<uses-permission android:name="android.permission.INTERNET" />

Snippet of code below.

Java.IO.File Files = new Java.IO.File(AppFolder + "/ServURL.txt");
            if (Files.Exists())
            {
                TextReader trs = new StreamReader(AppFolder + "/ServURL.txt");
                Job.ServiceIP = trs.ReadToEnd();
            }
            else
            {
                //Create ServURL.txt

                var jfs = new Java.IO.File(Path.Combine(AppFolder, "ServURL.txt"));
                var jfw = new Java.IO.FileWriter(jfs);

                jfw.Write("91.229.125.86");
                jfw.Close();
                TextReader trs = new StreamReader(AppFolder + "ServURL.txt");
                Job.ServiceIP = trs.ReadToEnd();
                Toast.MakeText(this, "Creating IP File", ToastLength.Short).Show();
            }

thanks

Posts

Sign In or Register to comment.