You can stick with creating a Uri object, or if you care about performance, use something similar to this:
public class UriHelpers { public static string GetFileNameFromUrl(string url) { string lastSegment = url.Split('/').Last(); return lastSegment.Substring(0, lastSegment.IndexOf('?') < 0 ? lastSegment.Length : lastSegment.IndexOf('?')); } }
ITmeze
source share