要引入using System.IO;
1,判断文件是否存在,如果存在删除
if (File.Exists(Path.GetFullPath(positonPath)))
{
File.Delete(Path.GetFullPath(positonPath));
}
2 .给文件重命名
FileInfo fileInfo = new FileInfo(fullpath);
string newFileName = “123abc”;
fileInfo.MoveTo(Path.Combine(fileInfo.DirectoryName, newFileName));