Developer

Manipulate URIs with Visual Studio .NET's System.URI class

Irina Medvinskaya explains how you use Visual Studio .NET's System.URI class to work with Uniform Resource Identifiers (URIs). This class allows you to represent and easily manipulate a given URI.

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 Listing A. The result of running this code looks like Figure 1.

In the code, I initially define a strURI variable and set its value to a link from the TechRepublic site. Then, I 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.

Miss a tip?

Check out the Visual Basic archive, and catch up on the most recent editions of Irina Medvinskaya's column.

Advance your scripting skills to the next level with TechRepublic's free Visual Basic newsletter, delivered each Friday. Automatically sign up today!

Editor's Picks

Free Newsletters, In your Inbox