![](/img/trans.png)
[英]How to store an image from http server to local folder? c# (win8, app)
[英]How to fill array of type image with images from a folder c# store app
我正在嘗試用紙牌創建游戲,我想將它們放入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;
}
}
您可以使用抽象類System.Drawing.Image
類的靜態方法來加載文件並獲取圖像的對象FromFile
Image.FromFile();
嘗試以下-
List<Image> imagelist = new List<Image>();
foreach (FileInfo oneFile in new DirectoryInfo("").GetFiles())
{
imagelist.Add(Image.FromFile(oneFile.FullName));
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.