You use the intLast variable in the following line:
string strOutput = strInput.Substring(strInput.Length - intLast);
But the variable will only matter under certain conditions ( strInput.Length > 1 and strInput.Substring(i, 1) == @"\" ). therefore a mistake.
To resolve this issue, specify a default value for the ad:
int intLast = 0; // or any default value.
source share