Move the if statement containing the flg.ShowDialog() call outside the foreach loop.