C# webrowser 控件设置打开页面问题
string strPath = Application.StartupPath;//表示该应用所在的起始目录 //strPath=“E:\C#project\MagicCony\MagicCony\bin\Debug”
strPath = strPath.Substring(0,strPath.LastIndexOf("\\"));//截取路径,
//strPath=“E:\C#project\MagicCony\MagicCony\bin”
strPath = strPath.Substring(0, strPath.LastIndexOf("\\"));
//strPath=“E:\C#project\MagicCony\MagicCony”
strPath += @"\search.htm";
//strPath=“E:\C#project\MagicCony\MagicCony\search.htm”
webBrowser1.Navigate(strPath);
这是给webrowser 控件设置打开页面的代码
Substring(int startindex,int length);
Startindex:表示开始截取位置;Length:表示截取长度;
lastindexof(string value);
在从零开始的字符串中,截取从0到最后一次出现字符串value的长度
strPath += @"\search.htm";
=strPath+="\\search.htm"