-
Apr 24th, 2018, 01:11 PM
#1
Thread Starter
Hyperactive Member
[Resolved] Path.Combine with drive references
If path1 is not a drive reference (that is, "C:" or "D:") and does not end with a valid separator character as defined in DirectorySeparatorChar, AltDirectorySeparatorChar, or VolumeSeparatorChar, DirectorySeparatorChar is appended to path1 before concatenation.
Debug.Print(Path.Combine("D:\Temp", "Foo")) returns D:\Temp\Foo , that's a right path
Debug.Print(Path.Combine("D:", "Foo")) returns D:Foo, that is NOT a valid path.
For what strange reason Path.Combine does'nt concatenate drive references??? In D: there can well be a Foo folder...
MORE: il Path2 starts with "\" Path.Combine returns only Path2. At this point is not more simple to use "&" to concatenate paths?
Last edited by phil2000; Apr 24th, 2018 at 02:34 PM.
-
Apr 24th, 2018, 01:37 PM
#2
Re: Path.Combine with drive references
Try using IO.Path.GetFullPath
Code:
Dim path As String = "C:"
path = IO.Path.Combine(IO.Path.GetFullPath(path), "Foo")
'
path = "C:\"
path = IO.Path.Combine(IO.Path.GetFullPath(path), "Foo")
-
Apr 24th, 2018, 02:33 PM
#3
Thread Starter
Hyperactive Member
Re: Path.Combine with drive references
Yes it works! Ty
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|