gpt4 book ai didi

c# - 如何在 iPhone 中显示/查找从 xamarin.ios 下载的图像?

转载 作者:太空宇宙 更新时间:2023-11-03 14:54:03 25 4
gpt4 key购买 nike

我们编写了一段代码,使用 xamarin.ios 中的 webclient 从 uri 下载图像。当我们下载图片时,它不会显示在图库/照片应用程序中,也不会显示在 iPhone 的任何其他位置。这是我的下载代码:

public void DownloadFiles()
{
try
{

var webClient = new WebClient();
webClient.DownloadDataCompleted += (s, e) => {
var bytes = e.Result;
string documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
string localFilename = "downloaded.png";
string localPath = Path.Combine(documentsPath, localFilename);

Console.WriteLine("localPath:" + localPath);

File.WriteAllBytes(localPath, bytes);

// IMPORTANT: this is a background thread, so any interaction with
// UI controls must be done via the MainThread
InvokeOnMainThread(() => {

// imageView.Image = UIImage.FromFile(localPath);

UIAlertView alert = new UIAlertView()
{
Title = "alert title",
Message = "Download successfully"
};
alert.AddButton("OK");
alert.AddButton("Cancel");
alert.Show();
});
};

var url = new Uri("https://www.xamarin.com/content/images/pages/branding/assets/xamagon.png");
webClient.DownloadDataAsync(url);
}
catch(Exception e)
{
throw e;
}
}

Environment.GetFolderPath(Environment.SpecialFolder.Personal);

如何找到这条路径?

最佳答案

我们在 info.plist 中添加了这些权限来解决这个问题。 “隐私 - 照片库添加使用说明”“隐私 - 照片库使用说明”

关于c# - 如何在 iPhone 中显示/查找从 xamarin.ios 下载的图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50564940/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com