Ich versuche, alle Dateien von rootFolderPath
zu destinationPath
Warum funktioniert File.Move nicht wie erwartet?
try
{
string rootFolderPath = @"D:\Log_siteq\";
if (!Directory.Exists(Path.Combine(@"D:\Log_takaya\" + comboBox1.SelectedItem.ToString())))
{
System.IO.Directory.CreateDirectory(Path.Combine(@"D:\Log_takaya\" + comboBox1.SelectedItem.ToString()));
}
string destinationPath = Path.Combine(@"D:\Log_takaya\" + comboBox1.SelectedItem.ToString());
string fileTypes = @"*.*";
string[] fileList = System.IO.Directory.GetFiles(rootFolderPath, fileTypes);
foreach (string file in fileList)
{
string ext = Path.GetExtension(file);
string destination = Path.Combine(destinationPath,file);
File.Move(file,destination);
MessageBox.Show(file);
MessageBox.Show(destination);
}
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
Offenbar MessageBox.Show(file);
zeigt mir Pfad mein Stammordner zu verschieben (wie normal), aber MessageBox.Show(destination);
ist mir die gleiche Sache zeigt.
Was gibt? Es verschiebt nur meine file
von meinem Stammordner in den gleichen Ordner.Am bekomme ich nichts?
nicht Path.Combine wie diese anwenden. Verwenden Sie nicht +, um Pfade zu kombinieren. Verwenden Sie wie folgt: Path.Combine ("D: \ Log_takaya", ComboBox1.SelectedItem.ToString()); –
Habe das nicht gesehen, rutschte mir. Aber das Problem bleibt, nichts hat sich geändert. –