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
Parameters
- baseDirectory
String. First path to be combined. Required.
- relativePath
String. Second path to be combined. Required.
Return Value
String.
Exceptions
The following condition may create an exception:
- Path is malformed (ArgumentException).
Remarks
This method trims excess slash-mark characters to create a properly formatted path.
Tasks
The following table lists examples of tasks involving the My.Computer.FileSystem.CombinePath method.
To | See |
---|---|
Combine a directory path and file name |
Example
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
.
Requirements
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 |
Permissions
The following permission may be necessary:
Permission | Description |
---|---|
Controls the ability to access files and folders. Associated enumeration: Unrestricted. |
For more information, see Code Access Security and Requesting Permissions.
See Also
Reference
My.Computer.FileSystem Object
My.Computer.FileSystem.GetParentPath Method
CombinePath