Esempio n. 1
0
    private void btnList_Click(object sender, EventArgs e)
    {
        string    startingPath;
        int       count;
        int       i;
        ArrayList dirs = new ArrayList();

        startingPath = @txtStartingPath.Text;

        try
        {
            DirectoryInfo myDirInfo = new DirectoryInfo(startingPath);
            if (myDirInfo.Exists == false)
            {
                MessageBox.Show("Cannot find directory. Re-enter.", "Directory Not Found");
                txtStartingPath.Focus();
                return;
            }
            clsDirectory myDirs = new clsDirectory();

            ShowDriveInfo();

            lstDirectories.Items.Clear();

            count = myDirs.ShowDirectory(myDirInfo, 0, dirs);
            for (i = 0; i < dirs.Count; i++)
            {
                lstDirectories.Items.Add(dirs[i]);
            }
            this.Text = "Directories found: " + count.ToString();
        }
        catch (Exception ex)
        {
            MessageBox.Show("Error: " + ex.Message, "IO Error");
            return;
        }
    }
Esempio n. 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            string startingPath;
            int count;
            int i;
            ArrayList dirs = new ArrayList();

            startingPath = @txtStartingPath.Text;

            try
            {
                DirectoryInfo myDirInfo = new DirectoryInfo(startingPath);

                if (myDirInfo.Exists == false)
                {
                    MessageBox.Show("Cannot find directory.  Re-enter.", "Directory not found.");
                    txtStartingPath.Focus();
                    return;
                }
                clsDirectory myDirs = new clsDirectory();
                ShowDriveInfo();
                lstDirectories.Items.Clear();

                count = myDirs.ShowDirectory(myDirInfo, 0, dirs);
                for (i = 0; i < dirs.Count; i++)
                {
                    lstDirectories.Items.Add(dirs[i]);
                }
                this.Text = "Directories found: " + count.ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message, "IO Error");
                return;
            }

        }