我现在卡在这个问题上很长时间了。我需要从Folder1\directory1复制(更新)所有内容到Updated\directory1,覆盖相同的文件但不删除已经存在于Updated\directory1但不存在于Folder1\directory1中的文件。为了让我的问题更清晰,这是我的预期结果:
C:\Folder1\directory1
subfolder1 subtext1.txt (2KB) subfolder2 name.txt (2KB)
C:\Updated\directory1
subfolder1 subtext1.txt (1KB) subtext2.txt (2KB)
预期结果:
C:\Updated\directory1
subfolder1 subtext1.txt (2KB) <--- updated subtext2.txt (2KB) subfolder2 <--- added name.txt (2KB) <--- added
我目前正在使用Directory.Move(source, destination),但是我在目标部分遇到了麻烦,因为它的一些目标文件夹不存在。我唯一的想法是使用String.Trim来确定是否有其他文件夹,但我无法真正使用它,因为目录应该是动态的(可以有更多的子目录或更多文件夹)。我真的很困惑。你能推荐一些提示或一些代码以让我的东西移动吗?谢谢!
C:\Folder1\directory1
subfolder1 subtext1.txt (2KB) subfolder2 name.txt (2KB)
C:\Updated\directory1
subfolder1 subtext1.txt (1KB) subtext2.txt (2KB)
预期结果:
C:\Updated\directory1
subfolder1 subtext1.txt (2KB) <--- updated subtext2.txt (2KB) subfolder2 <--- added name.txt (2KB) <--- added
我目前正在使用Directory.Move(source, destination),但是我在目标部分遇到了麻烦,因为它的一些目标文件夹不存在。我唯一的想法是使用String.Trim来确定是否有其他文件夹,但我无法真正使用它,因为目录应该是动态的(可以有更多的子目录或更多文件夹)。我真的很困惑。你能推荐一些提示或一些代码以让我的东西移动吗?谢谢!