显示源码:private void button2_Click(object sender, EventArgs e)
{
using (FileStream fs = File.Create(Path.ChangeExtension(openFileDialog1.FileName,".html"))) //创建建一个文本文件,并且把他的名称改为.html的
{
//写入数据
Byte[] info = new UTF8Encoding(true).GetBytes(
"<html> <body> <applet code=" + Path.GetFileName(textBox1.Text) + " " + "height=" + textBox2.Text + " " + "width=" + textBox3.Text + ">" + "</applet> </body> </html>"
);
fs.Write(info, 0, info.Length);
string i=Path.ChangeExtension(openFileDialog1.FileName,".html");
}
using (FileStream fs1 = File.Create(Path.ChangeExtension(openFileDialog1.FileName, ".bat")))
{
string i = Path.ChangeExtension(openFileDialog1.FileName, ".html");
Byte[] inf = new UTF8Encoding(true).GetBytes("D:"+Path.GetDirectoryName(textBox1.Text)+"appletviewer"+i);
fs1.Write(inf, 0, inf.Length);
Process.Start(Path.ChangeExtension(openFileDialog1.FileName, ".bat")); }
}我要做的就是点击按钮的时候,程序就自动生成一个文本文档,然后修改后缀名称为.html的,然后又自动生成了一个.bat的文件,里面存储了运行上面生成的.html的代码,但是为什么每次运行的时候,程序总是提示:”未处理的win32Exception 另一个程序正在实用此文件,进程无法访问“呢?
我已经确定在调试的时候,进程里没有多余的C# 程序在运行~~
{
using (FileStream fs = File.Create(Path.ChangeExtension(openFileDialog1.FileName,".html"))) //创建建一个文本文件,并且把他的名称改为.html的
{
//写入数据
Byte[] info = new UTF8Encoding(true).GetBytes(
"<html> <body> <applet code=" + Path.GetFileName(textBox1.Text) + " " + "height=" + textBox2.Text + " " + "width=" + textBox3.Text + ">" + "</applet> </body> </html>"
);
fs.Write(info, 0, info.Length);
string i=Path.ChangeExtension(openFileDialog1.FileName,".html");
}
using (FileStream fs1 = File.Create(Path.ChangeExtension(openFileDialog1.FileName, ".bat")))
{
string i = Path.ChangeExtension(openFileDialog1.FileName, ".html");
Byte[] inf = new UTF8Encoding(true).GetBytes("D:"+Path.GetDirectoryName(textBox1.Text)+"appletviewer"+i);
fs1.Write(inf, 0, inf.Length);
Process.Start(Path.ChangeExtension(openFileDialog1.FileName, ".bat")); }
}我要做的就是点击按钮的时候,程序就自动生成一个文本文档,然后修改后缀名称为.html的,然后又自动生成了一个.bat的文件,里面存储了运行上面生成的.html的代码,但是为什么每次运行的时候,程序总是提示:”未处理的win32Exception 另一个程序正在实用此文件,进程无法访问“呢?
我已经确定在调试的时候,进程里没有多余的C# 程序在运行~~
123.html
123.bat
我想要其中的123.bat运行,该如何得到123.bat这个文件名称呢