Hmm, it aint pretty but I think it works for what you want. You can set the target directory, it will open all folders inside of that and move the files one level higher. So for example, change c:\\ to F:\pc98\tetraquiz\ and it will copy any file from any folder inside that directory into that one if that makes sense? I think I could add another level so you did not have to alter the root directory but Ill have to think about it for a bit. Does this at all do what you wanted?
public void getDir()
{
//Substitute c:\\ string for root directory of folders
string[] fileEntries = Directory.GetDirectories(@"C:\\");
//Total number of directories inside that folder
int total = fileEntries.Length;
string[] targetDirectories = new string[total];
// MessageBox.Show(total.ToString());
for (int i = 0; i < total; i++)
{
int subIndex = fileEntries.LastIndexOf("\\");
targetDirectories = fileEntries.Substring(0, subIndex);
}
for (int i = 0; i < total; i++)
{
string[] fileNames = Directory.GetFiles(fileEntries);
foreach (string t in fileNames)
{
// MessageBox.Show(t);
// MessageBox.Show(targetDirectories);
int fileIndex = t.LastIndexOf("\\");
string fileName = t.Substring(fileIndex);
string fullPath = targetDirectories + fileName;
File.Move(t, fullPath);
}
}
}
It may be difficult to pick up all the root directories if there are certain ones you do not want to move from. Also I am not responsible for any damage that may becaused by this code lol (I did not provide error handling for overwriting of files). If you could provide a list of folder names to operate it could be programmed to read from that, or even a list of folders you do not want it operating on if that were smaller.
PS. If you want to operate on ALL folders inside of a single folder (PC98 in your example), it would be easy to modify it to do that.