ProgressBar is fairly simple to use. You need to set Minimum, Maximum and Value property of the ProgressBar.
Then in the loop use PerformStep method of the progressbar.
As per your e.g,
Get the length of the array string "filenames" using filename.length
string[] filenames = Directory.GetFiles(sTargetFolderPath);
and set it as maximum value of the progressbar
Set the Minimum value to 1
Within the loop, where the "foreach (string file in filenames)" block ends, just before the line use
progressbar1.PerformStep();
Here is a link which will give you a clear idea,
http://msdn.microsoft.com/en-us/library/system.windows.forms.progressbar.maximum.aspx[
^]
Hope this helps
cheers