其实已在运行了,你Hidden了
在批文件中加个暂停的,把 p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;不要
这样测试一下就清楚了 string str = System.Environment.CurrentDirectory;
str += "\\一键转换文件后缀名.bat";
string txt = "";
txt = "ren *" + textBox1.Text + " *" + textBox2.Text+"\r\n"; StreamWriter sw = new StreamWriter(str, false, Encoding.UTF8);
sw.Write(txt);
sw.Write("PAUSE");
sw.Close(); System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = str; //程序名称
p.StartInfo.Arguments = ""; //参数
//p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
p.Start();
在批文件中加个暂停的,把 p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;不要
这样测试一下就清楚了 string str = System.Environment.CurrentDirectory;
str += "\\一键转换文件后缀名.bat";
string txt = "";
txt = "ren *" + textBox1.Text + " *" + textBox2.Text+"\r\n"; StreamWriter sw = new StreamWriter(str, false, Encoding.UTF8);
sw.Write(txt);
sw.Write("PAUSE");
sw.Close(); System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = str; //程序名称
p.StartInfo.Arguments = ""; //参数
//p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
p.Start();
解决方案 »
- XML解析问题
- 求助!
- 创建一个抽象的窗体被警告!!!
- 弱弱的问个问题。很简单。开发winform的来
- c# QQ数据通信实现互聊怎么写啊
- 在WINFORM中怎样判断一个节点是否有子节点?
- 在winForm中有什么办法往windows2003的guests组中添加帐号、密码以及修改它的属性?
- 急!C#高手进!用C#创建一个万年历在控制台输出!
- 网页内嵌套另一页面,嵌套页面如何刷新?使用对象<OBJECT classid="clsid:8856F961-340A-11D0-A96B-00C04FD705A2" VIEWASTEXT>
- 思归大哥:有关命名空间的使用
- 请教个 try-catch (Exception )的问题
- 求助:关于抓取的数据用DatagridView显示
测试时先将窗口放出来,如一楼所说,将WindowStyle注释。而你的代码可以直接简化为:Process.Start(str);
这样运行这个Bat的时候就会有个窗体出来,方便看效果。
如果执行不成功,再看看上面代码哪里出了问题,如文件名是否正确,是否写入数据成功。
最后一步调用反而是最简单的。
foreach (var item in Directory.GetFiles("\\路径", "*.*"))
{
File.Move(item, 新名字);
}