private void RenameImage()
{
try
{
if (GlobalSetting.IsImageError || !File.Exists(GlobalSetting.ImageList.GetFileName(GlobalSetting.CurrentIndex)))
{
return;
}
}
catch { return; }
//Get filename
string oldName;
string newName;
oldName = newName = Path.GetFileName(
GlobalSetting.ImageList.GetFileName(GlobalSetting.CurrentIndex));
string currentPath = (Path.GetDirectoryName(
GlobalSetting.ImageList.GetFileName(GlobalSetting.CurrentIndex)) + "\\")
.Replace("\\\\", "\\");
//Get file extension
string ext = newName.Substring(newName.LastIndexOf("."));
newName = newName.Substring(0, newName.Length - ext.Length);
//Show input box
string str = null;
if (InputBox.ShowDiaLog(GlobalSetting.LangPack.Items["frmMain._RenameDialogText"], GlobalSetting.LangPack.Items["frmMain._RenameDialog"], newName, false) == DialogResult.OK)
{
str = InputBox.Message;
}
if (string.IsNullOrWhiteSpace(str))
{
return;
}
newName = str + ext;
//duplicated name
if (oldName == newName)
{
return;
}
try
{
//Rename file
ImageInfo.RenameFile(currentPath + oldName, currentPath + newName);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}