Will this code add multiple instance of image file in multipart form data content, will the content hold the pointer, after the using statement is complete, since the filestream will be disposed after that. I am not being able to fully grasp the filestream and its working along with other class that inherit from idisposable interface
This is just for my understanding and knowledge.
string[] filePath = { "DOC_Uploads_customerSNO_274385095233.jpg", "DOC_Uploads_customerSNO_523157478030.jpg" };
MultipartFormDataContent content = new MultipartFormDataContent();
string folderPath = Path.Combine(_webHostEnvironment.WebRootPath,"Uploads");
foreach (string file in filePath)
{
string imagePath = Path.Combine(folderPath, file);
using (FileStream filestream = new FileStream(imagePath, FileMode.Open, FileAccess.Read))
{
StreamContent streamContent = new StreamContent(filestream);
streamContent.Headers.ContentType = MediaTypeHeaderValue.Parse("multipart/form-data");
content.Add(streamContent, "file", Path.GetFileName(file));
}
}