Directory.GetFiles
を使用して、コピーされるファイルを検索しています。私はコピーを使用することができるようにファイルのパスを見つける必要がありますが、パスを見つける方法はわかりません。 ファイルを繰り返し処理しますが、ファイルのソースパスが必要なためコピーまたは移動できません。ディレクトリツリーの配列からのパス
string[] files = Directory.GetFiles(sourcePath, "*.*", SearchOption.AllDirectories);
System.Console.WriteLine("Files Found");
// Display all the files.
foreach (string file in files)
{
string extension = Path.GetExtension(file);
string thenameofdoom = Path.GetFileNameWithoutExtension(file);
string filename = Path.GetFileName(file);
bool b = false;
string newlocation = (@"\\TEST12CVG\Public\Posts\Temporaryjunk\");
if (extension == ".pst" ||
extension == ".tec" ||
extension == ".pas" ||
extension == ".snc" ||
extension == ".cst")
{
b = true;
}
if (thenameofdoom == "Plasma" ||
thenameofdoom == "Oxygas" ||
thenameofdoom == "plasma" ||
thenameofdoom == "oxygas" ||
thenameofdoom == "Oxyfuel" ||
thenameofdoom == "oxyfuel")
{
b = false;
}
if (b == true)
{
File.Copy(file, newlocation + thenameofdoom);
System.Console.WriteLine("Success: " + filename);
b = false;
}
}
それはより多くを持っていますが、私は必要だったものを入れて、私はそれを必要とします私が働いている私の仕事のために、私は必要ではなく、後でより早くです。 – shred1894
'Path.GetDirectoryName(filename)'を意味しますか? – mellamokb
ファイルが入っているフォルダだけでなく、パス全体が必要です。 – shred1894