有人可以给我一个在非静态环境中复制目录的提示/示例吗?我试图查找它,但没有这样的运气。
private void copybutton_Click(object sender, EventArgs e)
{
string selectedPath = comboBox1.SelectedItem.ToString();
copydirectories(@"C:\Mavro\MavBridge\" + selectedPath, @"C:\Mavro\MavBridge\" + selectedPath + " - Copy");
}
public void copydirectories()
{
try
{
string selectedPath = comboBox1.SelectedItem.ToString();
DirectoryInfo source = new DirectoryInfo(@"C:\Mavro\MavBridge\" + selectedPath);
DirectoryInfo target = new DirectoryInfo(@"C:\Mavro\MavBridge\" + selectedPath);
if (!source.Exists)
return;
if (!target.Exists)
target.Create();
DirectoryInfo[] sourceDirectories = source.GetDirectories();
for(int j = 0; j < sourceDirectories.Length; ++j)
{
copydirectories(sourceDirectories[j].FullName,target.FullName +"\\" + sourceDirectories[j].Name);
}
datemodified.Refresh();
}
这需要 2 个参数错误