2022年12月27日 星期二

[C#] 讀取資料夾裡所有圖檔

using System.IO;
using System.Drawing;


string folderPath = "C:\Images"; // 資料夾路徑
string[] filePaths = Directory.GetFiles(folderPath, "*.jpg"); // 取得資料夾中所有 JPG 圖檔的檔案路徑

foreach (string filePath in filePaths)
{
	Image image = Image.FromFile(filePath); // 讀取圖檔並建立 Image 物件
	// 在這裡可以進行圖檔的處理
}

沒有留言:

張貼留言