Click here to Skip to main content
15,919,121 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am using xamarin and i want to save txt file there so i have some script that is saving
C#
private void SavetoSd()
       {
           var sdCardPath = Android.OS.Environment.ExternalStorageDirectory.Path;
           var filePath = System.IO.Path.Combine(sdCardPath, "iootext.txt");
           if (!System.IO.File.Exists(filePath))
           {
               using(System.IO.StreamWriter write = new System.IO.StreamWriter(filePath,true))
               {
                   write.Write(etSipServer.ToString());
               }
           }

       }

but the error is that

C#
System.UnauthorizedAccessException: Access to the path "/mnt/sdcard/iootext.txt" is denied.

any help??

What I have tried:

in manifest i have added this
C#
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
	<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900