Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Flims, Switzerland
    Posts
    271
    Thanks
    0
    Thanked 0 Times in 0 Posts

    build a path (C#)

    If I have a folder path and a file name, what's the most elegant way of constructing the full path?

    Is there something somewhere (a static method?) which takes these two items as arguments and gives me back a path, or do I have to (ugh!) concatenate myself?

  2. #2
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: build a path (C#)

    Check out the System.IO.Path class.

    You'll find several helpful methods there.

  3. #3
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: build a path (C#)

    Sorry if I've missed something. Is there a problem with concatenate?
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  4. #4
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Flims, Switzerland
    Posts
    271
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: build a path (C#)

    Thanks, I've found it. It's Path.Combine().

  5. #5
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Flims, Switzerland
    Posts
    271
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: build a path (C#)

    There is nothing wrong with Concatenate(), however for the purpose of path concatenation I'd have to check the system's path seperator and also cater for the seperator already being present in the arguments. Path.Combine() does these steps for me so it's a little neater.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •