Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8334687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:26:07+00:00 2026-06-09T03:26:07+00:00

Part of my .NET application needs to take an input string (representing a URI)

  • 0

Part of my .NET application needs to take an input string (representing a URI) and return only the filename (and extension if applicable).

Now Path.GetFileName does this perfectly fine for most paths, with the following exception: if the input string is an HTTP path that consists only of a domain name (e.g. example.com) and port number (e.g. 10210), GetFileName returns the port number.

In simple English: the input string is http://example.com:10210, which is a URI that links to an internet radio stream.
When Path.GetFileName is called with that value, the return value is 10210.

Is this intended behavior? I can’t recall any platform that separates path segments with colons. Shouldn’t the return value be String.Empty?

EDIT

It seems like the clean solution would be a mashup between Uri.LocalPath and System.Web.VirtualPathUtility.GetFileName, but that implies re-targetting your project from a client profile to the full framework.

I think I’ll just go with removing everything before (and including) the last forward-slash symbol. The separator never changes in my scenario anyway. Doing that gives me example.com:10210 as the return value, which sort of makes sense for what I’m doing.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T03:26:09+00:00Added an answer on June 9, 2026 at 3:26 am

    Looking at the docs on the Path class, it doesn’t really appear that they intend you to use it with http or ftp or anything like that. All of the examples are around local file paths and network share paths.

    Based on some other anecdotal info from around the web, such as this article about Path.Combine, I’m led to believe that you shouldn’t use Path for HTTP.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working in ASP.NET c# application. I came to a part where I need
I have a regular .NET application. In this case I have a part that's
I have an ASP.NET MVC application that has one part where I dont really
In the Upshot.js library, that is part of the http://www.asp.net/single-page-application feature of ASP.NET MVC
Why is MODEL in ASP.NET MVC sometimes used as part of an application that
We have an application that is being moved to .NET. One part of the
I am working on a large web application implemented in ASP.net. The main part
As part of deployment process, I am starting an .net remoting windows forms application
Just working through a tutorial on asp.net/mvc for the music store application. Ref: http://www.asp.net/mvc/tutorials/mvc-music-store-part-3
Just a technology update, now that .NET 4.0 is out. I write an application

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.