473,508 Members | 2,324 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to obtain folder from Uri

I am trying to build a fairly simple spider, that takes in a Url,
downloads the page, extracts all links, and then downloads those.

The only problem I am struggling to crack is how to restrict the
downloaded links to only those from within the starting folder.

I am trapping the ResponseUri from the first Request in order to cope
with Redirection. From this I can determine the Host, but not the
folder.

e.g. if the Url = www17.brinkster.com/johnsmith/default.htm
I want www17.brinkster.com/johnsmith/
but the Host = www17.brinkster.com
the LocalPath = /johnsmith/default.htm

I would use the Uri.Segments, as this gives
1) /
2) johnsmith/
3) default.htm

so in this case I could remove the last item from the list, and build
my path from the rest.

But I have tried sites where the following segments would be listed
1) /
2) johnsmith

In which case I want all of them!

Is what I am trying to do possible?

Thanks,
Tony

Sep 11 '06 #1
1 2260
I have tried Path.GetDirectoryName(CustomerUrl.LocalPath)
which is useful for sites where the Uri contains the file to load as
well - e.g Home.html, Default.aspx

but for example: "http://news.bbc.co.uk/sport" returns "/sport" as the
LocalPath which is then gives a DirectoryName of "/" and a FileName of
"sport".

So the key bit I think is that both
/folder and /folder/file.aspx can point to the same thing, with some
sites using one construction and some the other.
How do I differentiate between the two?

Cheers,

Tony

Sep 11 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
7323
by: Sam | last post by:
Hi, I can use System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory() to obtain the path for ILASM.exe, but how can I obtain the path to ILDASM.exe? Examples of the path I'm...
5
6650
by: Jeronimo Bertran | last post by:
Hello, We have developed a socket tcpip server in .net that accepts calls from clients. Using the connected socket we are able to use the Socket.RemoteEndPoint to obtain the IP address of the...
1
3226
by: ASP .NET Newbie | last post by:
Hi everyone, What is the best method in C# to get the associated icon for a file? I've seen several different ways of doing this but they are all confusing to me. Basically, I am doing a...
2
1372
by: Adry | last post by:
Hi, how can I retrieve the system fonts folder ? or, better, from fontname how can I retrieve the font file complete path ? For example, having a "Tahoma" fontname, I would like to get the...
2
2387
by: James | last post by:
How to obtain the current users Temp folder %temp% using C# ?? Thanks in advance JIM
5
1376
by: Bob Alston | last post by:
Can anyone provide an invite or information on how I can obtain a trial version of the newest MS Access software? Bob
1
1290
by: =?Utf-8?B?TWFydGluVA==?= | last post by:
I have a problem to obtain the children in IIS when I create a folder directly in c:\inetput\wwwroot\*. If a create with Visual Studio it's OK. This is the code I use to obtain the object IIS. ...
2
2464
by: ME | last post by:
How would one obtain the parameter VALUES of a method that has already run? I can find the method using the StackTrace and StackFrame classes but once I find the method I would like to obtain the...
1
2646
by: lancer6238 | last post by:
Hi all, I'm writing a program using libpcap, and I have multiple pcap files in a folder that I want to capture. I currently have handle = pcap_open_offline("/data/traffic/pcap1.pcap",...
0
7224
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7323
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7379
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7493
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5049
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3180
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1550
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
763
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.