A step by step tutorial teaching you how to create your own chat client and chat server easily in C#, for local networks or the Internet.
A C# tutorial showing you how to make use of WMI to extract information on disk drives, such as model, capacity, sectors and serial number.
This tutorial will teach you how to calculate the shipping cost based on the weight, height, length and depth of the box, the distance and the UPS service type.
Creating a Rich Text Editor using JavaScript is easier to do than you might think, thanks to the support of modern browsers; this tutorial will walk you through it.
Using the URI ClassShows you how to parse a URI using the URI class and how to form an absolute URI from a base URI and a relative URI. |
On Saturday, June 26th 2004 at 02:25 AM By Andrew Pociu (View Profile) ![]() ![]() ![]() ![]() (Rated 4.2 with 19 votes) |
|||
Parsing a URICreate a new Windows Application project. Add two textBoxes and a button. The first textBox, name it txtURI. The second, name it txtResult and set the multiline property to True. Name the button btnParse. Do the rest of adjustments so that the form looks like the one below. First let's not forget to add a reference to the System.Net namespace.
Double click btnParse to get to the btnParse_Click() event. Here we shall use the following code:
First we clear txtResult from any prior parsing results. In the second line we create a new Uri using the URL in the textBox. Next comes a sequence of uri properties: AbsoluteUri property returns the complete URI. If you want you can call this the complete URI. AbsolutePath returns the absolute path used by the server. Local Path returns the local path of the file. Scheme gets the scheme of the current URI (ex.: file, http, ftp...). Authority returns a string composed from the host name / IP address and port number of the server. Host property returns a string with the host name / IP address of the server. Port gets the port of the server. Fragment returns the text followed by a marker (#) in an URI. Query gives you the query information from the URI (ex.: ?id=5). Here is an example result: ![]() There's another useful thing you can do using the Uri class:
|
||||
| Uri baseUri = new Uri(txtBase.Text); Uri absoluteUri = new Uri(baseUri, txtRelative.Text); txtAbsolute.Text = absoluteUri.ToString(); |
Digg It!
Del.icio.us
Reddit
StumbleIt
Newsvine
Furl
BlinkList
Rate this tutorial
Current CommentsHi,
The code given by u is not working.Plz send me the details.How to run the code step by step..Waiting for u'r mail
regards
Ashok
Any hints on how to deal with multiple querystrings? Is there a simple way to separate them out?
Related Tutorials
Related Source Code
C# Job Search