C#操作文件(复制、重命名、删除)

1.复制文件

File.Copy(filepath, filepath1);

将现有文件复制到新文件,不允许同名覆盖

2.文件重命名

FileInfo fi = new FileInfo(filepath1);
fi.MoveTo(Path.Combine(filepath1, filepath));

3.删除文件

File.Delete(filepath);

猜你喜欢

转载自ruohanfly.iteye.com/blog/2270326