Code: Select all
List fileStreams = new List();
foreach (var attachmentPath in attachmentPaths)
{
using (FileStream fileStream = new FileStream(
attachmentPath,
FileMode.Open,
FileAccess.Read,
FileShare.Read))
{
fileStreams.Add(fileStream);
}
}
DoSomethingWithFileStreams(fileStreams);
Code: Select all
List fileStreams = new List();
foreach (var attachmentPath in attachmentPaths)
{
FileStream fileStream = new FileStream(
attachmentPath,
FileMode.Open,
FileAccess.Read,
FileShare.Read);
fileStreams.Add(fileStream);
}
DoSomethingWithFileStreams(fileStreams);
foreach (var ifileStream in fileStreams)
{
ifileStream.Dispose();
}
Mobile version