如何删除“.pem”在文件名中 [英] How do I remove the ".pem" in the filename

查看:131
本文介绍了如何删除“.pem”在文件名中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

晚上好,



如何删除文件名中的.pem以更改为.ppk



Good evening,

How do I remove the ".pem" in the filename to change to ".ppk"

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SimplePEMCalculator
{
    class clsConvert
    {
        private string FilePath, OutputPath, WinSCPPath;
        public clsConvert(string fpath, string opath, string ppath)
        {
            FilePath = fpath;
            OutputPath = opath;
            WinSCPPath = ppath;
        }
     
        public int doConvert()
        {
            //try conversion 
            try
            {
                System.Diagnostics.Process process = new System.Diagnostics.Process();
                System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
                startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
                startInfo.FileName = WinSCPPath + "\\" + "winscp.com";
                //forming the ouput file by getting the input filename and adding the current date
                string outputfile = FilePath.Substring(FilePath.LastIndexOf("\\") + 1) + ".ppk" ;
                string op = OutputPath + "\\"+outputfile;
                startInfo.Arguments = "/keygen " + FilePath + " -o " + op;
                process.StartInfo = startInfo;
                process.Start();
                process.Close();
                return 1; 
            }
            catch
            {
                return 0;
            }
        }
    }
}





我尝试了什么:



我已经尝试了一些选项,并且出现空白且有错误。



再次感谢!



What I have tried:

I have tried some options and came up empty and with errors.

Thanks again!

推荐答案

作为Bruno(0x01AA [ ^ ])和 Philippe Mori [ ^ ]在问题的评论中提到,你必须使用路径类 [ ^ ],例如:

Path.GetFileName Method(String)(System.IO) [ ^ ]

Path.GetFileNameWithoutExtension Method(String)( System.IO) [ ^ ]

Path.GetExtension Method(String)(System.IO) [ ^ ]



试试吧!祝你好运!
As Bruno (0x01AA[^]) and Philippe Mori[^] mentioned in the comments to the question, you have to use Path class[^], for example:
Path.GetFileName Method (String) (System.IO)[^]
Path.GetFileNameWithoutExtension Method (String) (System.IO)[^]
Path.GetExtension Method (String) (System.IO)[^]

Try! Good luck!


这篇关于如何删除“.pem”在文件名中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆