Adam Neal
Adam Neal

Reputation: 2177

.NET Framework method to quickly build directories

Is there a quick way to join paths like the Join-Path function in Powershell? For example, I have two parts of a path "C:\foo" and a subdirectory "bar". Join-Path will join these and take care of the backslash delimiters. Is there a built-in method for this in .NET, or do I need to handle this myself?

Upvotes: 1

Views: 175

Answers (4)

Luke Bennett
Luke Bennett

Reputation: 32906

System.IO.Path.Combine

Upvotes: 1

torial
torial

Reputation: 13121

This is your friend: http://msdn.microsoft.com/en-us/library/system.io.path.combine.aspx

Upvotes: 7

Dario Solera
Dario Solera

Reputation: 5804

Path.Combine is the way to go.

Upvotes: 1

Rikalous
Rikalous

Reputation: 4574

System.IO.Path.Combine is the one you're looking for. There's quite a few useful methods on the Path class.

Upvotes: 2

Related Questions