How to create new file on external USB Mass Storage device on a Samsung TV with Tizen 5.0 with Xamarin.Forms?


I'm trying to create a new file with Xamarin.Forms on an external USB mass storage but I get an exception.

System.UnauthorizedAccessException: Access to the path '/opt/media/USBDriveA1/hello.txt' is denied. ---> System.IO.IOException: Permission denied

I believe I sign the app with a public certificate but I'm not sure I did the config right. I also added the following privileges to the tizen-manifest.xml:

I have the Tizen.NET nuget package in the multiplatform Xamarin.Forms project and the Tizen.NET.TV in the Tizen.TV project.

I tried with calling File.WriteAllText("/opt/media/USBDriveA1/hello.txt", "world") from the multiplatform project but it gave me the above exception.

I saw that the Web API has functionality to read and write files, is this possible from Tizen.NET?

Thanks in advance!




3 Replies
Tizen .NET

If you declared the privileges you mentioned, I think your app should work without any errors.
File creation and read/write in external storage worked well with simple test app.
Could you check it once with it?
If you can see the log (via sdb shell, Tizen Device Manager, or Tizen Log Viewer), please check if "" deny  occurs or not with DOTNET_LAUNCHER & CYNARA log tag.

Adam A-T


thank you for your answer.

I downloaded the test app you provided but when I try to start debugging it in Visual Studio, it freezes, and it never gets installed on the TV itself.

I couldn't check the logs, it seems like the TV disables logging. e.g. sdb capability prints log_enable:disabled.

I found out after more testing that when I have an external HDD at UsbDrive1 and a flash drive at UsbDrive2, the app can access the Flash Drive but gets the UnauthorizedAccessException for the External HDD.

The TV itself can use the HDD without problem.

I'm awaiting your insight,
Thank you.

Tizen .NET

Please check if externalstorage privilege is declared in tizen-manifest.xml file.