Export (0) Print
Expand All
Expand Minimize

My.Computer.FileSystem.CombinePath Method

Combines two paths and returns a properly formatted path.

' Usage
Dim value As String = My.Computer.FileSystem.CombinePath(baseDirectory ,relativePath)
' Declaration
Public Function CombinePath( _
   ByVal baseDirectory As String, _
   ByVal relativePath As String _
) As String

baseDirectory

String. First path to be combined. Required.

relativePath

String. Second path to be combined. Required.

The following condition may create an exception:

This method trims excess slash-mark characters to create a properly formatted path.

The following table lists examples of tasks involving the My.Computer.FileSystem.CombinePath method.

To

See

Combine a directory path and file name

How to: Parse File Paths in Visual Basic

This example combines a directory path and file name to create a properly formatted path.

Dim fullPath As String
fullPath = My.Computer.FileSystem.CombinePath _
("C:\Documents and Settings\All Users\Documents\My Pictures", "picture.jpg")

This example combines two paths to create a properly formatted path.

Dim fullPath As String
fullPath = My.Computer.FileSystem.CombinePath _
("C:\Dir1\Dir2\Dir3", "..\Dir4\Dir5\File.txt")

This example returns C:\Dir1\Dir2\Dir4\Dir5\File.txt.

Namespace: Microsoft.VisualBasic.MyServices

Class: FileSystemProxy (provides access to FileSystem)

Assembly: Visual Basic Runtime Library (in Microsoft.VisualBasic.dll)

Availability by Project Type

Project type

Available

Windows Application

Yes

Class Library

Yes

Console Application

Yes

Windows Control Library

Yes

Web Control Library

Yes

Windows Service

Yes

Web Site

Yes

The following permission may be necessary:

Permission

Description

FileIOPermission

Controls the ability to access files and folders. Associated enumeration: Unrestricted.

For more information, see Code Access Security and Requesting Permissions.

Community Additions

ADD
Show:
© 2014 Microsoft