把一种类型的多个文件合并成一个文件的控制台程序
static void Main(string[] args)
{
string currentDirectory = Environment.CurrentDirectory;
string[] files = Directory.GetFiles(currentDirectory, "*.sql");
string path = Path.Combine(currentDirectory, "all.sql");
using (FileStream stream = File.Create(path))
{
stream.Dispose();
}
foreach (string str3 in files)
{
string str4 = Path.Combine(currentDirectory, str3);
if (path.ToLower() != str4.ToLower())
{
string contents = File.ReadAllText(str4, Encoding.UTF8) + "\r\n";
File.AppendAllText(path, contents);
}
}
}
{
string currentDirectory = Environment.CurrentDirectory;
string[] files = Directory.GetFiles(currentDirectory, "*.sql");
string path = Path.Combine(currentDirectory, "all.sql");
using (FileStream stream = File.Create(path))
{
stream.Dispose();
}
foreach (string str3 in files)
{
string str4 = Path.Combine(currentDirectory, str3);
if (path.ToLower() != str4.ToLower())
{
string contents = File.ReadAllText(str4, Encoding.UTF8) + "\r\n";
File.AppendAllText(path, contents);
}
}
}