
Untitled
By: a guest on
Jan 4th, 2013 | syntax:
None | size: 1.74 KB | hits: 21 | expires: Never
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 '-'
}
return pth.Substring(pth.IndexOf('-')+1, pth.Length).Trim();
return pth.Substring(pth.IndexOf('-')+1).Trim();
private string title(string pth) //I'm passing a path
{
pth = System.IO.Path.GetFileNameWithoutExtension(pth); // I need an exact filename with no extension
string retStr = string.Empty;
if(pth.IndexOf('-')<pth.Length-1)
{
retStr = pth.Substring(pth.IndexOf('-')+1).Trim(); // trying to return everything after '-'
}
return retStr;
}
private static string title(string pth)
{
pth = System.IO.Path.GetFileNameWithoutExtension(pth); // I need an exact filename with no extension
Match m = Regex.Match(pth, @".*-(?<suffix>.*)$");
Group suffix = m.Groups["suffix"];
return suffix.Success ? suffix.Value : pth;
}
int index = pth.IndexOf('-');
return pth.Substring(index + 1, pth.Length - index - 1);
if(pth.IndexOf('-') != -1)
{
//Substring code
}
pth.Substring(pth.IndexOf('-')+1, pth.Length)
pth.Substring(pth.IndexOf('-')+1)
private string title(string pth) //I'm passing a path
{
pth = System.IO.Path.GetFileNameWithoutExtension(pth);
return pth.Substring(pth.IndexOf('-')+1, pth.Length - pth.IndexOf('-') - 1).Trim();
}
private string title(string pth) //I'm passing a path
{
pth = System.IO.Path.GetFileNameWithoutExtension(pth);
var indexOfDash = pth.IndexOf('-') + 1; // Add this line
return pth.Substring(indexOfDash, pth.Length - indexOfDash).Trim();
}