What's the equivalent of Path.GetDirectory()...

A

Arne Vajhøj

...for a web address.

Given
http://podcasts.mysite.com/podcasts/latest/latestepisode.mp3

how do I get
http://podcasts.mysite.com/podcasts/latest/

I actually tried using Path.GetDirectory() but ended up with

http:\\podcasts.mysite.com\\podcasts\\latest\\

This is for a C# WPF app.

I don't think there is anything builtin for this as URL's are
fundamentally not files.

What would you expect from:

http://podcasts.mysite.com/podcasts/latest/latestepisode.mp3/foo/bar?id-123

?

:)

So LastIndexOf seems as good or as bad as any other solution.

Arne
 
M

mick

I don't think there is anything builtin for this as URL's are
fundamentally not files.

What would you expect from:

http://podcasts.mysite.com/podcasts/latest/latestepisode.mp3/foo/bar?id-123

?

To be honest I don't know anything about webby stuff so I don't know what to
expect:)
I just assumed (hoped) there would be something similar in the web part of the
API.
:)

So LastIndexOf seems as good or as bad as any other solution.

Okidoke, thanks for your reply.

mick
 
A

Arne Vajhøj

To be honest I don't know anything about webby stuff so I don't know
what to expect:)
I just assumed (hoped) there would be something similar in the web part
of the API.

Full file names can be decomposed in:

drive (or host name for UNC)
directory
simple file name

URL's can be decomposed in:

protocol
optional username and password
host name
optional port number
path
optional query

Simply different.

..NET do have classes and methods to decompose a URL.

Arne
 
A

Arne Vajhøj

UriBuilder class might help - it will at least split the URI parts

The Uri also have some basic methods.

But that does not help much if the problem is not well defined.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

XPath issue 2
Podcasting 1
Free Podcasting Software Rocks 1
How to download an MP3 file. 5
files properties information 5
Frontpage - mp3 and itunes 1
File details 1
BBC iPlayer - Radio Downloader 6

Top