This is my code:
private string title(string pth) //I'm passing a path
{
pth = System.IO.Path.GetFileNameWithoutExtension(pth); // I need an exact filename with no extension
return pth.Substring(pth.IndexOf('-')+1, pth.Length).Trim(); // trying to return everything after '-'
}
It throws an exception. I have no idea why. It's an extremely easy way to get the title from filename, but it's not working.
I've tried pth.Length-1, but it's not working either.
-?