Someone could suggest me which properties i should use for It?tk
Loading
Someone could suggest me which properties i should use for It?tk
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jaish MathewsPosted Dec 29, 2024, 8:27 AM
To save images from a folder into a list of image objects in C#, you can use the
System.Drawing.Imageclass or theSystem.Windows.Media.Imaging.BitmapImageclass, depending on your application's requirements (e.g., Windows Forms, WPF).Here's a step-by-step guide: This may not provide the exact solution but will serve as a helpful guide.
Steps:
Directory.GetFilesto get all image file paths in the folder.Code Example:
Key Properties/Methods to Use:
Directory.GetFiles:Image.FromFile:Imageobject.List:Exception Handling:
Image.FromFilein atry-catchblock to handle cases where the file is not a valid image.Alternative for WPF (Using
BitmapImage):If you're working in a WPF application, use
System.Windows.Media.Imaging.BitmapImage:Tips:
System.Drawing.Imagefor Windows Forms or Console Applications.System.Windows.Media.Imaging.BitmapImagefor WPF applications.usingblocks or callDisposeonImageobjects when they're no longer needed.