Friday, February 3, 2012

Using FileOpen Dialog

        private void button1_Click(object sender, EventArgs e)
        {
            openFileDialog1.Title = "Open a file to process";
            //selectable file types
            openFileDialog1.Filter = "Portable Document Format (*.pdf)|*.pdf|Text Documents(*.txt)|*.txt";
            openFileDialog1.InitialDirectory = "c:\";
            DialogResult respo= openFileDialog1.ShowDialog();
            if (respo == DialogResult.OK)
            {
                textBox1.Text = openFileDialog1.FileName;
            }
            else
            {
                textBox1.Text = "No selected file!";
            }
        }

0 comments:

Post a Comment

© kani.stack.notez 2012 | Blogger Template by Enny Law - Ngetik Dot Com - Nulis