修改文件名

try
                {
                    string sFilePath = m_filePath + "\\" + m_fileName;
                    //string sName = m_filePath;  //无后缀

                    string sPostfix = m_fileName.Substring(m_fileName.LastIndexOf("."));//后缀

                    string sNewFileName = m_fileName.Substring(0, m_fileName.LastIndexOf(".")).Replace("_",".");//新文件名

                    FileInfo fInfo = new FileInfo(sFilePath);

                    string sFileName = fInfo.Directory + @"\" + sNewFileName + sPostfix;

                    System.IO.File.Move(sFilePath, sFileName);
                }
                catch (Exception ex)
                {
                }

你可能感兴趣的:(修改文件名)