Restrict if not a proper file using OpenFileDialog
<p>Hi all i have written a small code to open a particular text file. Now on open file dialog under the file name a drop down is displaying some file names if i select a file from that and click on ok i would like to display an error message as wrong file selected.</p>

<p>My code to open particular text file is as follows</p>

<pre><code>openFileDialog1.FileName = string.Empty;
strFilePath = Directory.GetCurrentDirectory();
strFilePath = Directory.GetParent(strFilePath).ToString();
strFilePath = Directory.GetParent(strFilePath).ToString();
strFilePath = strFilePath + "\\ACH";
openFileDialog1.InitialDirectory = strFilePath;
openFileDialog1.Filter = "(*.txt)|FileHeader*.txt";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
    try
    {
        if ((myStream = openFileDialog1.OpenFile()) != null)
        {
            using (myStream)
            {
                // Insert code to read the stream here.
                //FileName = openFileDialog1.FileName;
                txtFileHeader.Text = openFileDialog1.FileName.ToString(); ;
            }
        }
    }
    catch (Exception ex)
    {
        MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
    }

}
</code></pre>

<p>If any modifications to be done please let me know.</p>
