Ali G

Ali G

  • NA
  • 51
  • 38.4k

Passing the parameter...

Sep 30 2013 2:06 PM
pathname parameter which is created by button1_Click must be passed to button2_Click. How can I pass? (I know this is basic problem but I don't know.

===================================
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Drawing.Imaging;

namespace WindowsFormsApplication3
{
    public partial class Form1 : Form
    {
        string pathname;
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            DialogResult result = folderBrowserDialog1.ShowDialog();
            string pathname = @folderBrowserDialog1.SelectedPath;
            int foldercount = Directory.GetDirectories(@pathname).Length;
            int filecount = Directory.GetFiles(@pathname, "*.*", SearchOption.AllDirectories).Length;
            int JPGcount = Directory.GetFiles(@pathname, "*.JPG", SearchOption.AllDirectories).Length;

            label2.Text = pathname;
            label4.Text = foldercount.ToString();
            label6.Text = JPGcount.ToString();
            label8.Text = (filecount - JPGcount).ToString();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            FileInfo[] files = new DirectoryInfo(pathname).GetFiles("*.JPG");
==========================================


Answers (2)