我正在尝试相互交换 2 个文件。我正在尝试这样做,但它不起作用。文件正在替换,但备份文件未创建。请问您还有其他解决方案吗?
File.Replace(newLocation,defualtSource, newLocation);
最佳答案
File.Move("file1.txt", "temp.txt");
File.Move("file2.txt", "file1.txt");
File.Move("temp.txt", "file2.txt");
为什么 Replace 不起作用,但是我不明白。你确定你用对了吗?
关于c# - 我需要互相交换 2 个文件 C#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16544034/