且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

拒绝访问路径.

更新时间:2022-05-13 07:43:25

我假设您要用文件v替换文件.您现在的问题是第二个参数是一个文件夹,它应该是您要替换的文件.

如果您的文件夹包含2个文件(a.txt和b.txt),然后运行以下命令:
I assume you want to replace a file with the file v. Your problem now is that the 2nd argument is a folder, and it should be the file you want to replace.

If you have a folder with with 2 files (a.txt and b.txt) and run this:
File.Replace("a.txt", "b.txt", "b_old.txt");


您将最终得到b.txt(被称为a.txt)和b_old.txt(旧的b.txt).


如果您的目标只是进行备份.我建议使用File.Copy().


you will end up with b.txt(wich was called a.txt) and b_old.txt(the old b.txt).


If you goal is to just make a backup. I suggest using File.Copy().

System.IO.File.Copy(v.FullName, temppathmoment + @"MinecraftBackUP\" + v.Name + "_backup");



如果不是,则需要将文件路径而不是文件夹路径作为第二个参数.



If not you need to put a path to a file, not a folder as the 2nd argument.