gpt4 book ai didi

c# - Xamarin Forms - 检查 Environment.SpecialFolder.DesktopDirectory 中是否存在文件

转载 作者:行者123 更新时间:2023-11-30 21:33:05 25 4
gpt4 key购买 nike

在 Xamarin Forms 中,我们如何检查 Environment.SpecialFolder.DesktopDirectory 是否包含文件?

我正在使用以下命令从 azure 存储下载图像并将它们显示在页面上,它工作正常但我只想在不存在文件时这样做。

_activityIndicator.IsRunning = true;
var imgPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), "");
var blobList = await BlobStorageService.GetBlobs<CloudBlockBlob>("images");

foreach (CloudBlockBlob b in blobList)
{
Image _image = new Image();
imgPath = imgPath + b.Name;
await b.DownloadToFileAsync(imgPath, FileMode.Create);

StackLayout s = new StackLayout();
_title.Text = b.Name;
_image.Source = imgPath;
s.Children.Add(_title);
s.Children.Add(_image);
iStack.Children.Add(s);
}

最佳答案

你可以检查文件是否存在:

 if (File.Exists(imgPath))
{
**Write Your Code**
}

关于c# - Xamarin Forms - 检查 Environment.SpecialFolder.DesktopDirectory 中是否存在文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51764430/

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