语言

Menu
Sites
Language
File system API of C# throws exception even my app has privilege.

Hi.

 

I want to read & write some contents such as Videos, Documents, Downloads under "/opt/usr/media" in my Galaxy watch.

 

To do so, I added some C# file system API codes in my app, but it didn't work. It throws exception with message "Access to the path '/opt/usr/media/Downloads' is denied". Code is very simple:

 

String dirPath = "/opt/usr/media/Downloads";
FileSystemInfo[] directoryInfo = new DirectoryInfo(dirPath).GetDirectories();
FileSystemInfo[] fileInfo = new DirectoryInfo(dirPath).GetFiles();

 

I added all privileges which seems to be related with /opt/usr/media/Downloads such as below:

 

http://tizen.org/privilege/internet
http://tizen.org/privilege/network.get
http://tizen.org/privilege/network.profile
http://tizen.org/privilege/network.set
http://tizen.org/privilege/externalstorage
http://tizen.org/privilege/externalstorage.appdata
http://tizen.org/privilege/mediastorage
http://tizen.org/privilege/mediacontroller.server
http://tizen.org/privilege/mediacontroller.client
http://tizen.org/privilege/download
http://tizen.org/privilege/content.write

 

In spite of that, the code didn't work anyway.

 

I don't know why, but above code works with "/tmp" directory! Not only that, I can create a file under "/tmp" such as "/tmp/test.png". However, in this case, the created file can not be accessed by Tizen APIs such as `new MediaDatabase().ScanFile("/tmp/test.png")` and "Operation not permitted" exception is thrown.

 

The C# file system API behavior in Tizen is very very confusing :(

 

What can I do to solve these file access problem?

 

编辑者为: GO U 26 1月, 2019

响应

8 回复
Peter Wegner

IMHO Galaxy Watch means Tizen 4 device...

Maybe funny Security increased...

 

Did you tested something like this as path...

/home/owner/media/Downloads

 

Best Regards

GO U

Thanks for your reply, and yes, Galaxy Wath has Tizen 4.

 

But anyway, path cahnging couldn't help me. The result is same :(

GO U

Thanks for your reply, and yes, Galaxy Wath has Tizen 4.

 

But anyway, path cahnging couldn't help me. The result is same :(

Peter Wegner

Thanx for feedback.

 

Sorry no idea...

I have no idea if any dotNet Samples exists... nor if attempt in Emulator on PC deliver other result...

IMHO public dotNet support is old outdated... non existing...

As since months nothing really new for Wearables is available...

 

No idea if something helpfull is here:

https://github.com/Samsung

https://github.com/Samsung/xamarin-forms-samples

 

Meanwhile we have also Tizen 4 for Gear S3 device(s)...

SM-R760 and SM-R770 have DSA1... SM-R765T and SM-R775T and SM-R765 + SM-R775S from Korea "base"...

 

I hope somebody can help you...

 

Best Regards

 

Peter Wegner

https://developer.tizen.org/development/guides/.net-application

 

No idea if here something usefull to find...

 

Best Regards

Peter Wegner

https://tizen.myget.org/feed/dotnet/package/nuget/Tizen.NET

 

Oh funny... I thought Tizen 5.5 is latest...

Seems Tizen 6...

No wonder why they have no time for instructions etc...

 

Best Regards

Sangwook Kim

FYI, the next Tizen platform version is supposed to be 5.5 and its C# API level is 6.

Please refer to https://github.com/Samsung/TizenFX#branches.

Sangwook Kim

You will only need a media storage privilege ("http://tizen.org/privilege/mediastorage") to get an access to the specified directory.

As of Tizen 4.0 and later, media storage privilege is treated as user privacy privilege (https://developer.tizen.org/development/training/native-application/understanding-tizen-programming/security-and-api-privileges?langswitch=en).

Please see the instructions in https://developer.tizen.org/ko/development/guides/.net-application/security/privacy-related-permissions and let your application properly request the permission by using PrivacyPrivilegeManager.RequestPermission().

Best Regards