小问题,大家来看看

HNU 2004-03-24 03:30:58
private void zcqd2_Click(object sender, System.EventArgs e)
{

foreach(int i in listBox1.SelectedIndices)
{

Process myProcess = new Process();

myProcess.StartInfo.FileName = @"d:\" + listBox1.Items[i].ToString()+".url"; //用IE打开.url文件

myProcess.StartInfo.CreateNoWindow = false;
//上面已经是打开新窗口了啊!true也一样

myProcess.Start();

}
}



我点击按钮打开listBox1中对应名字的网页,但是不是新打开IE窗口,而是把我已经打开的IE窗口覆盖,我想打开新窗口怎么解决?
...全文
43 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
HNU 2004-03-27
  • 打赏
  • 举报
回复


例外加100分
HNU 2004-03-26
  • 打赏
  • 举报
回复




楼上的:

string url 为一个“xxx.URL”文件,不是直接的地址,如“www.csdn.net”

用静态Start()会出现“文件下载”的WINDOWS报错框,提示不能用这种方式打开,不安全。。。


csxtu 2004-03-26
  • 打赏
  • 举报
回复
你只要这样就可以打开新的窗口了:


string url =this.listBox1.Items[this.listBox1.SelectedIndex].ToString () ;

Process.Start("IExplore.exe", url);
HNU 2004-03-25
  • 打赏
  • 举报
回复


zhzuo(秋枫)


你这样写还是会覆盖我已经打开过的网页

static void Process.Start() 可以新开窗口,但是用不上
HNU 2004-03-25
  • 打赏
  • 举报
回复

看看。。。
marvelstack 2004-03-24
  • 打赏
  • 举报
回复
//设置为类里面的变量
Process myProcess = null;

foreach(int i in listBox1.SelectedIndices)
{

myProcess = new Process();

myProcess.StartInfo.FileName = @"d:\" + listBox1.Items[i].ToString()+".url"; //用IE打开.url文件

myProcess.StartInfo.CreateNoWindow = false;
//上面已经是打开新窗口了啊!true也一样

myProcess.Start();

}
使用完之后结束进程
myProcess.Kill();
HNU 2004-03-24
  • 打赏
  • 举报
回复
3
HNU 2004-03-24
  • 打赏
  • 举报
回复
2
HNU 2004-03-24
  • 打赏
  • 举报
回复


楼上的,你的代码肯定要覆盖以前打开过的网页。

csxtu 2004-03-24
  • 打赏
  • 举报
回复
我这样写的,没有错;



private void listBox1_Click(object sender, System.EventArgs e)
{
Process myprocess=new Process ();
myprocess.StartInfo.FileName =this.listBox1.Items[this.listBox1.SelectedIndex].ToString () ;
myprocess.Start();
}
HNU 2004-03-24
  • 打赏
  • 举报
回复
1

111,125

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧