0

I've got a string containing a processname like

string name = "firefox.exe", now I need to remove only the ".exe" part, so I get the processname without the ending. I tried to use

   Console.WriteLine("output: " + processName.TrimEnd('.','e','x','e'));

But for some reasons output seems to be "firefo" without the "x". Any idea how to get this solved in an easy and clean way?

1

1 Answer 1

5

You ask it to trim the characters ., e and x from the end, so it does that:

firefox.exe
firefox.ex
firefox.e
firefox.
firefox
firefo

how to get this solved in an easy and clean way?

Using Path.GetFileNameWithoutExtension().

1
  • Path.GetFileNameWithoutExtension() solved :).
    – dehner
    Dec 19, 2014 at 10:34

Not the answer you're looking for? Browse other questions tagged or ask your own question.