私はしばらくの間、この問題にかなり悩まされています。Folder1\directory1 から Updated\directory1 にすべてをコピー (更新) して同じファイルを上書きする必要がありますが、Updated\directory1 に既に存在するが Folder1\directory1 には存在しないファイルは削除しません。私の質問をより明確にするために、これは私の予想される結果です:
C:\フォルダ1\ディレクトリ1
サブフォルダー1
subtext1.txt (2KB)
サブフォルダー2
名前.txt (2KB)
C:\更新済み\ディレクトリ1
サブフォルダー1
subtext1.txt (1KB)
subtext2.txt (2KB)
期待される結果:
C:\更新済み\ディレクトリ1
サブフォルダー1
subtext1.txt (2KB) <--- 更新
subtext2.txt (2KB)
subfolder2 <--- 追加
name.txt (2KB) <--- 追加
現在使用してDirectory.Move(source, destination)
いますが、宛先フォルダーの一部が存在しないため、宛先部分に問題があります。私の唯一のアイデアは、String.Trim
追加のフォルダーがあるかどうかを判断するために使用することですが、ディレクトリは動的であると想定されているため、実際には使用できません (サブディレクトリまたはフォルダーが増える可能性があります)。私は本当に立ち往生しています。私のものを動かすためのヒントやコードをお勧めできますか? ありがとう!