So the problem is this I declare the variables and open the stream at the begining of the method:
int i = 0;
int FailedToCopyImages = 0;
int NumberOfCopiedImages = 0;
int PreviouslyCopiedImages = 0;
TextWriter tw = new StreamWriter(pathToFile, true);
Then I do some stuff in try-catch-finally
block and in the `finally part I have :
finally
{
Console.WriteLine(i);
Console.WriteLine(NumberOfCopiedImages);
Console.WriteLine(PreviouslyCopiedImages);
Console.WriteLine(FailedToCopyImages);
tw.WriteLine(" ");
tw.WriteLine("All images: " + i +
" | Successfully copied: " + NumberOfCopiedImages +
" | Previously copied: " + PreviouslyCopiedImages +
" | Failed To Copy: " + FailedToCopyImages);
tw.WriteLine("--------------End Of Material Images-------------");
I do this in four methods and I get the right results there. Here in the Console I see that the variables holds the correct value but in the txt file I get zeroes (0).