Please could a C# expert help with a simple problem which for some strange reason I just can’t seem to work out? I’m trying to move multiple sub folders in the current directory to a new directory and keep the subfolder name, see below:
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.");
}
}
At the moment, I only seem to be able to move one folder instead of all of the them.
Any help would be greatly appreciated!
I suppose you want this: