Created
February 18, 2011 07:49
-
-
Save thecodejunkie/833391 to your computer and use it in GitHub Desktop.
Get file name + extension from a resource name
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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