文件名软件字符删除更新日志20231108

文件名软件字符删除更新日志20231108,用户反馈软件的字符删除功能报错,现在新的算法记下日志,以便查看。

private static bool rename_process(DataTable dataTable)
{
    try
    {
        ConfigInfo configInfo = getConfigInfo();
        string column_name = Spirit.Common.Utils.GetColumnName(dataTable);

        foreach (DataRow dr in dataTable.Rows)
        {
            string column_value = (string)dr[column_name];
            string name = column_value;
            string extension = "";
            if (column_name == Spirit.Common.Utils.NewFileName)
            {
                name = Path.GetFileNameWithoutExtension(column_value);
                extension = Path.GetExtension(column_value);
            }
            int index = 0, count = 0;

            string newName = "";
            if (configInfo.IsFront)
            {
                index = configInfo.IndexFront.Value;
                count = configInfo.CountFront.Value;
                newName = DeleteSubstring(name, index, count);
            }
            else
            {
                name = Common.Utils.ReverseString(name);     //从后开始删除,反转自符串
                index = configInfo.IndexBack.Value;
                count = configInfo.CountBack.Value;
                newName = DeleteSubstring(name, index, count);
                newName = Common.Utils.ReverseString(newName);
            }

            dr[column_name] = Common.Utils.Trim(newName) + extension;
        }
        return true;
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
        return false;
    }
}

public static string DeleteSubstring(string input, int start, int count)
{
    if (start >= input.Length) return input;
    if ((start + count) > input.Length)
    {
        return input.Substring(0, start);
    }
    StringBuilder sb = new StringBuilder(input);
    sb.Remove(start, count);
    return sb.ToString();
}
批量修改文件名 2024年最新版 完全免费
批量修改文件名称、文件夹名称

方便快捷,支持正则表达式、无需安装功能齐全、支持定制无广告、无插件,放心使用。

免费下载 百度网盘
本站中所有的计算器的计算结果仅供参考,本站对此结果的准确性不承担任何责任,实际数额以银行/保险公司/国家相关机构确认的结果为准。
在线客服QQ:543690914,备案号: 苏ICP备15037649号-33。东海县白塔埠镇佳诚电脑经营部版权所有。