To combine two parts of a file path, you can do
System.IO.Path.Combine (path1, path2);
However, you can’t do
System.IO.Path.Combine (path1, path2, path3);
Is there a simple way to do this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As others have said, in .NET 3.5 and earlier versions there hasn’t been a way to do this neatly – you either have to write your own
Combinemethod or callPath.Combinemultiple times.But rejoice – for in .NET 4.0, there is this overload:
There are also overloads taking 3 or 4 strings, presumably so that it doesn’t need to create an array unnecessarily for common cases.
Hopefully Mono will port those overloads soon – I’m sure they’d be easy to implement and much appreciated.