4
Answers

trying to launch process with dynamic context menuitem

Chris

Chris

14y
2.9k
1
I've got a program in which I'm using a notifyicon only.

Most of it is drawn at design time, but i have one dropdown that comes from run time.
I can get this to draw the dropdown items and populate with directories and files with a Dropdown_opening event.

The problem is that I'm not able to get it to launch a process (in the form of a window when clicked on a directory or running a program for a file).

Here's a snippet of code that I'm using:

private void myStuffToolStripMenuItem_DropDownOpening(object sender, EventArgs e)
        {
            DirectoryInfo dir = new DirectoryInfo(@"E:\My Stuff");
            foreach(DirectoryInfo name in dir.GetDirectories())
            {
                //add directories found in folder
                myStuffToolStripMenuItem.DropDownItems.Add(name.Name);
            }

            FileInfo fil = new FileInfo(@"E:\My Stuff");
            foreach(FileInfo name in fil.Directory.GetFiles())
            {
                //add files found as well
                myStuffToolStripMenuItem.DropDownItems.Add(name.Name);
            }
        }

Thank you for any help you can give.

I'm new to programming and learning on my own (with little help from the web/other users), so please be patient.

Answers (4)