1
Answer

How can i use a Process to open a directory for browsing ?

Daniel Lipman

Daniel Lipman

11y
1.1k
1
Hi,

What i want to do is two things:

1. Button click in an event will use a Process to open a directory so i can see the directory like explorer.
2. When i close the window of the directory/process an event Exited of the Process will rise.

What i did so far is in Form1 top added:

private Process zipFileDirectoryProcess;

Then in the constructor i did:

zipFileDirectoryProcess = new Process();
zipFileDirectoryProcess.StartInfo.FileName = "explorer.exe";
zipFileDirectoryProcess.StartInfo.CreateNoWindow = true;
zipFileDirectoryProcess.EnableRaisingEvents = true;
zipFileDirectoryProcess.Exited += new EventHandler(zipFileDirectoryProcess_Exited);


Then in i have a method i call it from a button click event inside the method i did:

zipFileDirectoryProcess.StartInfo.WorkingDirectory = t;
zipFileDirectoryProcess.Start();//= Process.Start(Path.GetFullPath(t));
this.TopMost = true;

What i want is that the process will open/show the directory variable: t

If i was doing: zipFileDirectoryProcess = Process.Start(Path.GetFullPath(t)); then it will open the directory but then the event Exited never fire.

Then in the bottom of Form1 i have:

private void zipFileDirectoryProcess_Exited(object sender, EventArgs e)
        {
            this.TopMost = false;
        }


So how can i do that the process also open the directory variable: t and also will raise the event zipFileDirectoryProcess_Exited ?

Answers (1)