class Program
{
static void Main(string[] args)
{
try
{
replacefile rf = new replacefile();
rf.doReplace(@"F:\c1");
rf.doReplace(@"F:\c2");
rf.doReplace(@"F:\c3");
Console.WriteLine("替换完成!");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
public class replacefile
{
public string sourceFilejs = @"F:\frmleftdown.js";//源文件
public string sourceFilexml = @"F:\frmleftdown.xml";//源文件
public void doReplace(string parentPath)
{
string[] files = Directory.GetFiles(parentPath);
foreach (string f in files)
{
if (f=="frmleftdown.js") File.Copy(sourceFilejs, f, true);//替换目录下所有的同名文件
if (f=="frmleftdown.xml") File.Copy(sourceFilexml, f, true);
}
string[] subdirs = Directory.GetDirectories(parentPath);
foreach (string subdir in subdirs)
{
doReplace(subdir);
}
}
}