Skip to content

Instantly share code, notes, and snippets.

@thecodejunkie
Created February 18, 2011 07:49
Show Gist options
  • Save thecodejunkie/833391 to your computer and use it in GitHub Desktop.
Save thecodejunkie/833391 to your computer and use it in GitHub Desktop.
Get file name + extension from a resource name
static string GetResourceFileName(string resourceName)
{
var nameSegments =
resourceName.Split(new[] { "." }, StringSplitOptions.RemoveEmptyEntries);
var segmentCount =
nameSegments.Count();
return (segmentCount < 2) ?
string.Empty :
string.Format("{0}.{1}", nameSegments.ElementAt(segmentCount - 2), nameSegments.Last());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment