|
|
Title | Resolve relative paths in VB.NET |
Description | This example shows how to resolve relative paths in VB.NET. It uses Path.Combine and then Path.GetFullPath. |
Keywords | path, special folders, VB.NET |
Categories | Windows, 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
|
|
|
|
|
|