读书人

封闭进程

发布时间: 2012-12-17 09:31:40 作者: rapoo

关闭进程
用模板生成静态页,但是生成的html文件有的不能访问,关闭VS在重新打开就可以访问了
怎样用代码关闭现在的进程


protected void Button1_Click(object sender, EventArgs e)
{
StreamWriter sw = null;
StreamReader sr = null;
string htmlfilename = "";
string str1 = "";
string path1 = HttpContext.Current.Server.MapPath("i.htm");//模板
string path = HttpContext.Current.Server.MapPath("~/html/");//生成文件放在html文件夹下
try
{
sr = new StreamReader(path1, Encoding.GetEncoding("GB2312"));
str1 = sr.ReadToEnd();
}
catch (Exception ex)
{
throw ex;
}
finally
{
sr.Close();
sr.Dispose();
}
try
{
for (int i = 0; i < 4; i++)
{

htmlfilename = ""+ i +".html";
sw = new StreamWriter(path + htmlfilename, false, Encoding.GetEncoding("GB2312"));
str1 = str1.Replace("$i$", i.ToString());
sw.Write(str1);
sw.Flush();
}
}
catch (Exception ex)
{
HttpContext.Current.Response.Write(ex);
HttpContext.Current.Response.End();
}
finally
{
sw.Close();
sw.Dispose();
}
}

错误
我想用代码关闭现在的进程,应该怎么关,我又不知道现在进程的名字
大神直接来段能用的代码吧


[最优解释]

Process.GetCurrentProcess().Kill();

[其他解释]
关闭应该是w3wp.exe进程吧
[其他解释]
引用:
C# code?



1

Process.GetCurrentProcess().Kill();


需要引用什么
[其他解释]
引用:
引用:C# code?
Process.GetCurrentProcess().Kill();
需要引用什么


using System.Diagnostics;
[其他解释]
引用:
引用:
引用:C# code?
Process.GetCurrentProcess().Kill();
需要引用什么

using System.Diagnostics;

Process.GetCurrentProcess().Kill();之后我的整个后台都不能运行了,能不能只关闭某个进程,比如生成页面的进程,或者关闭进程后,在重新打开进程
[其他解释]

着急啊,有没有人啊
[其他解释]
引用:
着急啊,有没有人啊


你先找到是哪哥进程,关闭进程这, 百度一下,最少也有十几页
[其他解释]
问题解决了。

读书人网 >asp.net

热点推荐