How can I get a list of network files from my mono for android application?

若如初见. 提交于 2019-12-11 10:31:56

问题


I've been messing around with Mono for Android for a little while now. I am wondering how (or if it's possible) to access network files located on my NAS.

I was really hoping it was going to be as easy as

var files = System.IO.Directory.GetFiles("\\NAS-NAME\SomeDirectory\", "*");

Unfortunately, I'm getting this error message, so I'm guessing it's not quite as straight forward as a standard .NET application:

Unhandled Exception:

System.IO.DirectoryNotFoundException: Directory '\\NAS-NAME\SomeDirectory\' not found.

回答1:


I'm guessing it's not quite as straight forward as a standard .NET application:

Standard .NET applications have all of WinAPI to build upon, e.g. FileStream.Write uses WinAPI WriteFile, which supports UNC paths. Android is Linux, and thus doesn't have a "complete" WinAPI implementation, and CIFS/SMB is beyond the scope of Mono for Android (and normal Mono for that matter), hence the error.

You should try using an alternate networking protocol, e.g. does your NAS support WebDAV? There are a number of C# WebDAV libraries that can be easily ported to Mono for Android...



来源:https://stackoverflow.com/questions/14176444/how-can-i-get-a-list-of-network-files-from-my-mono-for-android-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!