我正在尝试在Visual Studio 2017跨平台中创建包含图像的文件夹并将其复制到设备上,然后访问它以显示图像。到目前为止,我是使用嵌入式资源来完成此操作的,但这对我来说不起作用,因为现在我想将图像上传到同一文件夹中。
在安装应用程序时如何使用图像创建文件夹?
这就是我正在读取文件的方式。
var resourceName = assembly.GetManifestResourceNames();
for (int columnrow = 0; columnrow < resourceName.Length; columnrow++)
{
for (int rowIndex = 0; rowIndex < 2; rowIndex++)
{
if (counter >= resourceName.Length)
{
break;
}
var img = new Image
{
Source = FileImageSource.FromResource(resourceName[counter]),
Aspect = Aspect.Fill,
};
var tapGestureRecognizer = new TapGestureRecognizer();
tapGestureRecognizer.Tapped += (sender, e) =>
{
// cast to an image
Image theImage = (Image)sender;
Navigation.PushModalAsync(new ImageViewPopUp(theImage));
// now you have a reference to the image
};
img.GestureRecognizers.Add(tapGestureRecognizer);
// ImageList.ColumnDefinitions[rowIndex] = new ColumnDefinition { Width = new GridLength(700,GridUnitType.Star)};
ImageList.Children.Add(img, rowIndex, columnrow);
counter++;
}
}
如果要将这些图像保存在真实文件夹中,则可以提取它们并将其保存到应用程序Environment.GetFolderPath (Environment.SpecialFolder.Personal);
文件夹中。
该页面显示了部署数据库时的操作方法,但是任何嵌入式资源都将以相同的方式工作。
https://robgibbens.com/deploying-a-database-file-with-a-xamarin-forms-app/
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句