C# 给文件重命名
给文件重命名,我们需要使用到函数: File.Move()函数
string smallMatPath = @" F:\test\4.bmp";
string oldFilename = Path.GetFileNameWithoutExtension(smallMatPath);//"4"
string newFilename = oldFilename + "_ng";//"4_ng"
string path1 = Path.GetDirectoryName(smallMatPath);//"F://test"
File.Move(smallMatPath, path1 + "//" + newFilename + ".bmp");//"F://test//4_ng.bmp"