Nick Reshetinsky wrote:
f I created that "scope" and i put FileInfo references there
so after the closing bracket they would be out of scope and thus
they will be popped out of stack....Right? Will it save memory that
my application uses? Or will it simply destroy references and will
not free up heap memory where FileInfo references point?
Yes and no. When the "files" array goes out of scope at the end of the block, all the elements of the array (all the FileInfo variables) are available for garbage collection, because nothing else refers to them. They won't however be deleted until the GC actually gets round to it - which may be immediately, or may be next year. It really doesn't matter!
Without actually measuring it (and I don't have time at the moment) I would be suprised if
this.pictureBox.Image = Image.FromStream(fs);
was significantly slower than
this.pictureBox.Image = new Bitmap(pathNameString);
as I would expect the Bitmap constructor to use a stream anyway...
Did you try
this.pictureBox.Image = Image.FromFile(pathNameString);
and if so did that make any difference?