Rename File Extension
using System; using System.Diagnostics; using System.IO; public static class FileInfoExt { public static bool RenameFileExtension(this FileInfo iFileInfo, string iNewFileName)//test it { if (iFileInfo != null && string.IsNullOrEmpty(iNewFileName) == false) { if (iFileInfo.Exists) { string vNewExtension = iNewFileName; if (iNewFileName[0] == '.') { vNewExtension = iNewFileName.Substring(1); } string vNewName = iFileInfo.Name.Replace(iFileInfo.Extension, "." + vNewExtension); string vNewFullName = iFileInfo.DirectoryName + vNewName; try { iFileInfo.MoveTo(vNewFullName); if (File.Exists(vNewFullName)) { return true; } } catch (Exception) { } } } return false; } }