如何使用文件夹c#store应用程序中的图像填充类型图像的数组

如何使用文件夹c#store应用程序中的图像填充类型图像的数组,c#,.net,arrays,C#,.net,Arrays,我正在尝试用卡片创建一个游戏,我想把它们放在Image类型的数组中,但问题是我想用文件夹(资产/卡片)中的52.png文件填充它。我该怎么做?我知道我必须使用存储文件夹,但我似乎无法理解,如果有人能帮助我,我将非常高兴。我只有一个空数组 void DeckCard() { Image[] Deck = new Image[52]; for (int i = 1; i <= Deck.Length; i++) { Deck[i] = new Image

我正在尝试用卡片创建一个游戏,我想把它们放在
Image
类型的数组中,但问题是我想用文件夹(资产/卡片)中的52.png文件填充它。我该怎么做?我知道我必须使用存储文件夹,但我似乎无法理解,如果有人能帮助我,我将非常高兴。我只有一个空数组

void DeckCard()
{
    Image[] Deck = new Image[52];
    for (int i = 1; i <= Deck.Length; i++)
    {
        Deck[i] = new Image();
        Deck[i].Margin = new Thickness(0, 0, 0, 0);
        LayoutRoot.Children.Add(Deck[i]);
        Deck[i].Height = 200;
        Deck[i].Width = 100;
    }
}
void DeckCard()
{
图像[]组=新图像[52];

对于(int i=1;i您可以使用抽象类的静态方法
System.Drawing.Image
class加载文件并从文件中获取Image
object

Image.FromFile()

试试下面-

List<Image> imagelist = new List<Image>();

foreach (FileInfo oneFile in new DirectoryInfo("").GetFiles())
{
    imagelist.Add(Image.FromFile(oneFile.FullName));
}
List imagelist=new List();
foreach(FileInfo-oneFile在新的DirectoryInfo(“”.GetFiles()中)
{
Add(Image.FromFile(oneFile.FullName));
}

您可以使用抽象类的静态方法
System.Drawing.Image
类加载文件,并从文件中获取图像的对象

Image.FromFile()

试试下面-

List<Image> imagelist = new List<Image>();

foreach (FileInfo oneFile in new DirectoryInfo("").GetFiles())
{
    imagelist.Add(Image.FromFile(oneFile.FullName));
}
List imagelist=new List();
foreach(FileInfo-oneFile在新的DirectoryInfo(“”.GetFiles()中)
{
Add(Image.FromFile(oneFile.FullName));
}

我会使用数据库文件或xml文件将图像存储为字节数组。字节数组非常容易跳转、存储和绘制图像。这样你就不需要存储52个图像文件,只需要一个数据文件。我想使用图像数组im与数据库文件和字节数组不常见。我会使用数据库文件或xml文件以字节数组的形式存储图像。字节数组非常容易在图像中来回移动、存储和绘制。这样,您就不需要存储52个图像文件,只需要一个数据文件。我想使用图像数组,我与数据库文件和字节数组不相同,我不能使用“目录”,这是windows应用商店应用程序,我不能使用“目录”这是一个windows应用商店应用程序