Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleResolve relative paths in VB.NET
DescriptionThis example shows how to resolve relative paths in VB.NET. It uses Path.Combine and then Path.GetFullPath.
Keywordspath, special folders, VB.NET
CategoriesWindows, VB.NET, Files and Directories
 
The user fills in the base path and the relative path, and then clicks the Go button. The program uses the Path.Combine method to combine the two paths. This method simply concatenates the paths, however. For example, "C:\Hello\World" plus "..\Universe" gives the result "C:\Hello\World\..\Universe" which is probably not what you want.

The program then calls the Path.GetFullPath method to convert this into an absolute path.

 
Private Sub btnGo_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles btnGo.Click
    txtResult.Text = Path.GetFullPath( _
        Path.Combine(txtBase.Text, txtRelative.Text))
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated