comp • gb • file • setdir

File.SetDir (gb)

Static Function SetDir ( Path As String, NewDir As String ) As String

Sets the directory part of a path, and returns the modified path.

Examples

Dim filePath As String

Print "* A standard type of path"
filePath = "/my/path/file.ext"
Print filePath
Print File.SetDir(filePath, "/new/path")

Print "\\n* Set a relative path"
filePath = "my/path/file.ext"
Print filePath
Print File.SetDir(filePath, "new/path")

Print "\\n* Add a path to a file and extension"
filePath = "file.ext"
Print filePath
Print File.SetDir(filePath, "/new/path")

Print "\\n* Change a path without a file name and extension"
filePath = "my/path/"
Print filePath
Print File.SetDir(filePath, "new/path/")

* A standard type of path
/my/path/file.ext
/new/path/file.ext

* Set a relative path
my/path/file.ext
new/path/file.ext

* Add a path to a file and extension
file.ext
/new/path/file.ext

* Change a path without a file name and extension
my/path/
new/path/