【发布时间】:2012-07-19 00:19:26
【问题描述】:
如何在 C# Windows 控制台应用程序中实现此伪代码?
for i=1 to 100
rename filei newFilei
关键目标是在 Windows 控制台应用程序中循环和执行任何 cmd 命令。
class Program
{
static void Main(string[] args)
{
string strCmdLine;
System.Diagnostics.Process process1;
process1 = new System.Diagnostics.Process();
Int16 n = Convert.ToInt16(args[1]);
int i;
for (i = 1; i < n; i++)
{
strCmdLine = "/C xxxxx xxxx" + args[0] + i.ToString();
System.Diagnostics.Process.Start("CMD.exe", strCmdLine);
process1.Close();
}
}
}
【问题讨论】:
-
显示你写的代码...
-
这还能编译吗?这看起来像是来自 Java 的粗略翻译
-
您可以考虑将您的问题改为
Can I repeatedly execute commands on windows command prompt "DOC" using C#?。 -
请不要在你的问题前加上标签。
标签: c# .net windows console-application