简体   繁体   English

如何从Mono for Android应用程序获取网络文件列表?

[英]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. 我一直在搞乱Android版Mono。 I am wondering how (or if it's possible) to access network files located on my NAS. 我想知道如何(或是否有可能)访问位于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: 不幸的是,我收到此错误消息,所以我猜想它不如标准.NET应用程序那么直接:

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: 我猜它不如标准的.NET应用程序那么直接:

Standard .NET applications have all of WinAPI to build upon, eg FileStream.Write uses WinAPI WriteFile , which supports UNC paths. 标准.NET应用程序具有所有WinAPI都可以构建,例如FileStream.Write使用WinAPI WriteFile (它支持UNC路径)。 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. Android是Linux,因此没有“完整”的WinAPI实现,并且CIFS / SMB不在Android的Mono范围内(对于此问题而言,是普通的Mono),因此会出现错误。

You should try using an alternate networking protocol, eg does your NAS support WebDAV? 您应该尝试使用备用网络协议,例如您的NAS是否支持WebDAV? There are a number of C# WebDAV libraries that can be easily ported to Mono for Android... 有许多C#WebDAV库可以轻松移植到Android版Mono ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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