配置文件-帮助尝试让它与路径和鼠标悬停工作

本文关键字:路径 鼠标 悬停 工作 帮助 配置文件 | 更新日期: 2023-09-27 18:18:37

我遇到了一个问题,试图让我的Windows窗体应用程序与配置文件一起工作,我在这里和其他地方读了不少帖子,但我仍然无法弄清楚如何让它工作,因此我的问题在这里,我正在我的第一个应用程序上工作。我已经添加了配置。Manager .dll到我的项目。我还试图通过配置文件路径获得MouseHover工作。

配置文件是这样读的

<configuration>
  <appSettings>
    <add key="Google" value="http://www.google.com/"/>
   </appSettings>
</configuration>

应用程序中的前一个路径字符串

//public static string Google = @"http://www.google.com/";

下面的第一行工作正常。

//System.Diagnostics.Process.Start(Google);

但是这个我根本无法工作,我已经尝试了各种各样的例子。

System.Diagnostics.Process.Start(ConfigurationManager.AppSettings["Google"]);

代码一起

private void GoogleW_Click(object sender, EventArgs e)
{
  try
  {
    //System.Diagnostics.Process.Start(Google);
    System.Diagnostics.Process.Start(ConfigurationManager.AppSettings["Google"]);
  }
  catch (Exception e)
        {
            MessageBox.Show(e.Message);
        }
 }

鼠标移到

上也是一样
//ToolTip1.SetToolTip(this.GoogleW, @Google);

但是没有这个,我找不到任何说明你可以使用配置文件的鼠标在文本。

ToolTip1.SetToolTip(this.GoogleW, (ConfigurationManager.AppSettings["Google"]));

Code Together

private void GoogleW_MouseHover(object sender, EventArgs e)
{
  System.Windows.Forms.ToolTip ToolTip1 = new System.Windows.Forms.ToolTip();
  //ToolTip1.SetToolTip(this.GoogleW, @Google);
  ToolTip1.SetToolTip(this.GoogleW, (ConfigurationManager.AppSettings["Google"]));

配置文件-帮助尝试让它与路径和鼠标悬停工作

您是否尝试在web.config文件中添加http://www.google.com/而不是www.google.com/ ?

更新:也如上所述,@ajg它的explorer.exe不是exploror.exe

你真的不需要指定进程名,除非你特别需要打开Internet Explorer,而不是系统默认的web浏览器。我个人讨厌程序强行打开ie浏览器,而不是我的默认浏览器。

Process.Start(ConfigurationManager.AppSettings["Google"]);

成功了!

应用程序。配置文件

<add key="Google"  value="http://www.google.com/" />

代码
private void GoogleS_Click(object sender, EventArgs e)
        {
            try
            {
                //MessageBox.Show(ConfigurationManager.AppSettings["Google"]);
                string GoogleS = ConfigurationManager.AppSettings["Google"];
                Process.Start(GoogleS);
            }
            catch (Exception GoogleErr)
            {
                MessageBox.Show(GoogleErr.Message);
            }
        }
        private void GoogleS_MouseHover(object sender, EventArgs e)
        {
            System.Windows.Forms.ToolTip ToolTip1 = new System.Windows.Forms.ToolTip();
            ToolTip1.SetToolTip(this.GoogleS, (ConfigurationManager.AppSettings["Google"]));
        }