I have the following class.
public class Foo
{
private string _DirName;
private FileStream _MyfileStream;
public FileStream MyfileStream
{
get { return _MyfileStream; }
}
public string DirName
{
get { return _DirName; }
set
{
_DirName = value;
_MyfileStream = new FileStream(value, FileMode.Create);
}
}
}
I have Created a List Of Foo as like the following:
List<Foo> FooList = new List<Foo>();
FooList.Add(new Foo() { DirName = @"F:\sample\sample.txt" });
FooList.Add(new Foo() { DirName = @"D:\sample\file.pdf" });
So each list item is creating a File stream. hence the number of streams increased as the number of list item increases. how can i dispose the allocated memory for these streams?