RestImageResize/Utils/UriExtentions.cs
/// <summary>
/// Gets the requested file name.
/// </summary>
/// <param name="uri">The URI.</param>
/// <returns>
/// The file name, if some file is requested; otherwise empty string.
/// </returns>
Gets the requested file name.
Gets the requested file name .
public static string GetFileName(this Uri uri)
        {
            string uriPath;
            if(uri.IsAbsoluteUri)
            {
                uriPath = uri.LocalPath;
            }
            else
            {
                uriPath = uri.OriginalString;
                int queryStartMarkIndex = uriPath.IndexOf('?');
                if (queryStartMarkIndex > 0)
                {
                    uriPath = uriPath.Substring(0, queryStartMarkIndex);
                }
            }
            string filePath = (uriPath).Replace('/', '\\');
            string fileName = Path.GetFileName(filePath);
            return fileName;
        }
public static string GetFileName ( this Uri uri ) { string uriPath ; if ( uri . IsAbsoluteUri ) { uriPath = uri . LocalPath ; } else { uriPath = uri . OriginalString ; int queryStartMarkIndex = uriPath . IndexOf ( ' ' ) ; if ( queryStartMarkIndex > 0 ) { uriPath = uriPath . Substring ( 0 , queryStartMarkIndex ) ; } } string filePath = ( uriPath ) . Replace ( ' ' , ' \\ ' ) ; string fileName = Path . GetFileName ( filePath ) ; return fileName ; }
Gets the requested file name.
Gets the requested file name .
The file name, if some file is requested; otherwise empty string.
The file name if some file is requested ; otherwise empty string .
Uri
this
uri
None