Я пытаюсь отобразить изображения из такой папки:
Код: Выделить всё
// Path to the folder containing photos
string folderPath = "";
// Get all the image file paths from the folder
string[] imagePaths = System.IO.Directory.GetFiles(folderPath, "*.png");
// Create a stack layout to hold the photo squares
StackLayout stackLayout = new StackLayout();
// Iterate through each image path
foreach (string imagePath in imagePaths)
{
// Create an image view with the current photo
Image photoImage = new Image
{
Source = ImageSource.FromFile(imagePath),
Aspect = Aspect.AspectFill // Adjust aspect ratio of the image
};
// Create a square container for the photo
Frame photoFrame = new Frame
{
CornerRadius = 10, // Optional: Round the corners of the frame
Padding = 5,
BackgroundColor = Colors.LightGray, // Optional: Set background color
Content = photoImage,
Margin = new Thickness(10) // Optional: Add margin between squares
};
// Add the photo square to the stack layout
stackLayout.Children.Add(photoFrame);
}
The problem is that while I know the correct path to the images when executing in windows, from an android phone I can't find the images in the application folder in /data.
Knowing that the path needed by
Код: Выделить всё
System.IO.Directory.GetFiles(folderPath, "*.png");I am new to MAUI and I have never worked with applications before, and I know that it probably is an extremely easy fix, but I can't seem to find a way.
Источник: https://stackoverflow.com/questions/781 ... n-net-maui
Мобильная версия