我有一大堆纯文本文件,命名如下:file1.txt,file2.txt,...,file14.txt,...我想将它们按正确顺序连接到一个 .txt 文件。我应该如何以编程方式执行此操作?在命令窗口中运行的批处理文件?或者编写一个 Windows 控制台应用程序?
无论哪种方式,我可以有代码吗?谢谢。
更多信息:
大量文件。每次我做这个报告时,一百个或更多。
dir 不会以正确的顺序给出文件:例如 file10.txt 出现在 file2.txt 之前,这就是我强调的原因。似乎从 1 到 n 的 for i 连接到文件名前缀是最好的。但我不知道如何在批处理模式下执行此操作或从 Windows 程序执行命令。
我倾向于做一个 Windows 控制台应用程序。这样的事情会起作用吗?
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 copy more work here " + args[0] + i.ToString();
System.Diagnostics.Process.Start("CMD.exe", strCmdLine);
process1.Close();
}
}
}