hi, have a slight problem here.

this is my open file dialog code.

private void browseToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Title = "Browse And Upload A Template.";
            ofd.Filter = "All files (*.*)|*.*|All files (*.*)|*.*";

           DialogResult dr = ofd.ShowDialog();

          
            if (dr == DialogResult.OK)
            {
                //bitmap = (Bitmap)Bitmap.FromFile(ofd.FileName);
                //setup(true);
                System.IO.StreamReader sr = new System.IO.StreamReader(filename);

                Form activeChildForm = this.ActiveMdiChild;

               // filename = ofd.FileName;
                pictureBox3.Image = Image.FromFile(ofd.FileName);
                Image imgPhotoVert = Image.FromFile(ofd.FileName);
                Image imgPhotoHoriz = Image.FromFile(ofd.FileName);
                Image imgPhoto = null;
                imgPhoto = FixedSize(imgPhotoVert, 720, 500);
                pictureBox3.Image = imgPhoto;


                if (activeChildForm != null)
                {
                    TextBox activeTextBox = (TextBox)activeChildForm.ActiveControl;

                    if (activeTextBox != null)
                        activeTextBox.Text = sr.ReadToEnd();

                    sr.Close();
                }


                else
                {

                    return;

                }
            }

        }

how am i to read in the file that was opened by the dialog into other functions?

i want to read in the file that i had selected from the open file dialog into this function call ZOOM ;

private void btnZoomOut_Click(object sender, EventArgs e)
        {
            zoomCounter--;
            // ZOOM OUT


     [B]       Image imgPhotoVert = Image.FromFile();
            Image imgPhotoHoriz = Image.FromFile(filename);[/B]

the bold area is the one that has error. PLS help. thank u.

>how am i to read in the file that was opened by the dialog into other functions?

Through the method arguments. Pass a filename or a reference of FileInfo object to that method.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.