Results 1 to 3 of 3

Thread: [Resolved] Path.Combine with drive references

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2009
    Posts
    459

    [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.

  2. #2
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,754

    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")
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    May 2009
    Posts
    459

    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
  •  



Click Here to Expand Forum to Full Width