简体   繁体   中英

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

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.

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, eg 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, eg does your NAS support WebDAV? There are a number of C# WebDAV libraries that can be easily ported to Mono for Android...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM