相关疑难解决方法(0)

C# - 如何从路径中提取文件名和扩展名?

所以,说我有

string path = "C:\\Program Files\\Program\\File.exe";
Run Code Online (Sandbox Code Playgroud)

我如何只获得"File.exe"?我正在考虑拆分(见下文),但我尝试的东西不起作用......

这是我的代码.

        List<string> procs = new List<string>(); //Used to check if designated process is already running
        foreach (Process prcs in Process.GetProcesses())
            procs.Add(prcs.ProcessName); //Add each process to the list
        foreach (string l in File.ReadAllLines("MultiStart.txt")) //Get list of processes (full path)
            if (!l.StartsWith("//")) //Check if it's commented out
                if (!procs.Contains(l.Split('\\')[l.Split('\\').Length - 1])) //Check if process is already running
                    Process.Start(l);
Run Code Online (Sandbox Code Playgroud)

我可能只是一个菜鸟.._.

c# file path

25
推荐指数
3
解决办法
6万
查看次数

标签 统计

c# ×1

file ×1

path ×1