Hi
i am creating web api for displaying the all images from the folder haveing images
below is my code, but it displaying the last image from the folder.
HttpResponseMessage Response = new HttpResponseMessage(HttpStatusCode.OK);
string[] filesindirectory = Directory.GetFiles(HttpContext.Current.Server.MapPath("~/images"));
List<String> images = new List<string>(filesindirectory.Count());
foreach (string item in filesindirectory)
{
images.Add(String.Format("~/images", System.IO.Path.GetFileName(item)));
byte[] fileData = File.ReadAllBytes(item);
Response.Content = new ByteArrayContent(fileData);
}
Response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
return Response;