Click here to Skip to main content
15,905,233 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to read image files located in D:/Image folder
Posted

IF you you want to directly show the image you can easily specify the path of the image as source of image object in C# as

C#
Image myImg = Image.FromFile("path here");
Bitmap myBmp = Bitmap.FromFile("path here");


Alternatively a Bitmap object can also be loaded with:

C#
Bitmap myBmp = new Bitmap("path here");


Or to open a dialog box for image

C#
Bitmap loadedBitmap = Bitmap.FromFile(openFileDialog1.Filename);


Or if you want to save your image in DB or want to read it in a Memory stream try this

Back to Basics – Reading a File into Memory Stream[^]
 
Share this answer
 
Simply by doing for a defined image:
C#
Image img = new Image();
img.ID = "myImage";
img.ImageUrl = @"D:/Images/Someimage.png":


To pick all the images, you need to use DirectoryInfo and FileInfo to get all the files in the defined folder. Based on the extension, read the files. (Image extensions in your case.)
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900