public bool Rename(string FileNameAndPath, string NewName)
{
bool ret = false;
System.IO.FileInfo fi = new System.IO.FileInfo(FileNameAndPath);
if (!fi.Exists)
return ret;
string NewFilePathName = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(FileNameAndPath), NewName);
System.IO.FileInfo f2 = new System.IO.FileInfo(NewFilePathName);
try
{
if (f2.Exists)
{
f2.Attributes = System.IO.FileAttributes.Normal;
f2.Delete();
}
fi.CopyTo(NewFilePathName);
fi.Delete();
ret = true;
}
catch
{
}
return ret;
}