请问C#专家是否可以解决一个简单问题,由于某种奇怪的原因,我似乎无法解决这个问题?我想在当前目录中移动多个子文件夹到一个新的目录,并保持子文件夹名称,见下图:将多个子文件夹移动到不同的目录并保留文件夹名称
public string currentDirectory = System.Environment.GetEnvironmentVariable("LOCALAPPDATA") + @"\Test\CurrentFolder\";
public string newDirectory = System.Environment.GetEnvironmentVariable("LOCALAPPDATA") + @"\Test\NewFolder\";
private void btnMoveFolder_Click(object sender, RoutedEventArgs e)
{
string[] subdirectoryEntries = Directory.GetDirectories(currentDirectory);
try
{
foreach (string subCurrentDirectory in subdirectoryEntries)
{
Directory.Move(subCurrentDirectory, newDirectory);
}
}
catch (System.Exception)
{
Log("Problem with moving the directory.");
}
}
此刻,我只能似乎能够移动而不是所有的一个文件夹的他们。
任何帮助将不胜感激!
sooo ...你正在使用的代码是什么_problem_(除格式:))? – sehe