using System;
using System.Diagnostics;
using System.IO;
public static class FileInfoExt
{
public static bool RenameFileName(this FileInfo iFileInfo, string iNewFileName)
{
if (iFileInfo != null && string.IsNullOrEmpty(iNewFileName) == false)
{
if (iFileInfo.Exists)
{
string vExtension = iFileInfo.Extension;
string vNewFileName = iNewFileName + vExtension;
string vNewFullName = iFileInfo.DirectoryName + vNewFileName;
try
{
iFileInfo.MoveTo(vNewFullName);
if (File.Exists(vNewFullName))
{
return true;
}
}
catch (Exception)
{
}
}
}
return false;
}
}