我想要将文件从一个文件夹移动到另一个(目标)文件夹,相同的文件已经存在于目标文件夹中,我想重命名.how以在C#中实现。
提前感谢Sekar
发布于 2009-10-13 12:02:25
System.IO.File.*拥有您需要的一切。
System.IO.File.Exists =检查文件是否存在。System.IO.File.Move =移动(或重命名文件)。
发布于 2009-10-13 04:00:26
从根本上讲,这是:
string source = ..., dest = ...; // the full paths
if(File.Exists(dest))
{
File.Move(dest, Path.GetTempFileName());
}
File.Move(source, dest);发布于 2009-10-13 04:01:51
您将希望使用System.IO.File类,并提前检查文件是否存在。
if(File.Exists("myfile.txt"))
File.Move("myfile.txt", "myfile.bak");
File.Move("myotherfile.txt","myfile.txt");https://stackoverflow.com/questions/1558121
复制相似问题