Uniform Resource Identifiers (URIs) may represent Web requests, FTP requests, files, news, and e-mail. Whenever you need to work with URIs and determine a particular portion of a given URI, you can utilize the System.URI class available in Visual Studio .NET. This class allows you to represent and easily manipulate a given URI.
To create an example, add a ListBox control to your form and call it ListBox1. Then, add the code in Snippet A.
Snippet A
In the code, we initially define a strURI variable and set its value to a link from the Go4Expert forums. Then, we add the following properties of the URI object strURI to the ListBox1 control: Scheme, Host, Path, Query, Type, Port. The ListBox1 control simply displays the selected properties of the strURI object.
To create an example, add a ListBox control to your form and call it ListBox1. Then, add the code in Snippet A.
Snippet A
Code: VB
Private Sub GetURIInfo()
Dim strURI As New Uri("http://www.go4expert.com/showthread.php?p=10432")
With ListBox1.Items
.Clear()
.Add("Scheme: " & strURI.Scheme)
.Add("Host: " & strURI.Host)
.Add("Path: " & strURI.AbsolutePath)
.Add("Query: " & strURI.Query)
.Add("Type: " & strURI.HostNameType.ToString())
.Add("Port: " & strURI.Port)
End With
End Sub