C#方法中没有采用“0”个参数重载
小弟在网上找了个将一个文件夹下的东西复制到另一个文件夹下,自己谢了下,出现错误:C#方法中没有采用“0”个参数重载
代码如下,请大神们指出,说的清楚些,小弟谢谢啦!
private bool CopyFloderContents(string OldPath, string NewPath)
{
OldPath = OldPath.EndsWith(@"D:\123") ? OldPath : OldPath + @"D:\123";
NewPath = NewPath.EndsWith(@"D:\aaa") ? NewPath : NewPath + @"D:\aaa";
try
{
if (Directory.Exists(OldPath))
{
if (Directory.Exists(NewPath) == false)
{
Directory.CreateDirectory(NewPath);
}
foreach (string files in Directory.GetFiles(OldPath))
{
FileInfo fileinfo = new FileInfo(files);
fileinfo.CopyTo(string.Format(@"{0}\{1}", NewPath, fileinfo.Name), true);
}
foreach (string drs in Directory.GetDirectories(OldPath))
{
DirectoryInfo directoryInfo = new DirectoryInfo(drs);
if (CopyFloderContents(drs, NewPath + directoryInfo.Name) == false)
{
return false;
}
}
}
return true;
}
catch (Exception ex)
{
return false;
}
}
private void button1_Click(object sender, EventArgs e)
{
CopyFloderContents();//CopyFloderContents方法中没有采用“0”个参数重载
}
}