所以我有这段代码从我的FTP服务器获取图像,然后我要从ftp服务器设置其源。我从这行cannot convert 'System.IO.Stream' to 'System.Func<System.IO.Stream>'
那里得到的imgs.Source = ImageSource.FromStream(img);
我正在Android btw上使用xamarin.Forms。
private void loadImage(string source)
{
try
{
string ftpfullpath = source;
FtpWebRequest ftp = (FtpWebRequest)FtpWebRequest.Create(ftpfullpath);
ftp.Credentials = new NetworkCredential(ftpusername, ftppassword);
ftp.KeepAlive = true;
ftp.UseBinary = true;
ftp.Method = WebRequestMethods.Ftp.DownloadFile;
using (var request = ftp.GetResponse())
{
using (var img = request.GetResponseStream())
{
imgs.Source = ImageSource.FromStream(img);
}
}
}
catch (Exception ex)
{
}
}