Is there a way to close a particular instance of explorer with C#?

后端 未结 4 2057
故里飘歌
故里飘歌 2020-12-01 19:17

I\'m looking for a way to close a Windows explorer window that\'s open to a certain folder. Say c:\\users\\bob\\folder. I can close all explorers with the code below, but th

4条回答
  •  Happy的楠姐
    2020-12-01 19:27

    foreach (Process p in Process.GetProcessesByName("explorer"))
    {
        if (p.MainWindowTitle.Contains("YourFolderName"))
        {
            p.Kill();
        }
    }
    

提交回复
热议问题