所以,说我有C# - 如何从路径中提取文件名和扩展名?
string path = "C:\\Program Files\\Program\\File.exe";
如何获得唯一 “的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);
我可能只是一个noob。 ._。
我的代码需要Path.GetFileNameWithoutExtension,但是谢谢... – CrimsonDeath
这不是什么哟你的问题说,虽然。 – Joey