Two things:
First, you need to escape the backslash by using two of them:
this.GetCountOfOccurance(path,'\\');
Since the backslash character is a "special" in C# which introduces other characters such as newline: '\n', quote: '\'' and doublequote: '\"'.
Secondly, there are a huge number of ways to do this:
Counting Lines in a String[
^] covers a good number of them!