How to join two paths in C #?

How to join two file paths in C #?

+78
c # file path
Jun 07 '09 at 11:02
source share
2 answers

You should use Path.Combine () , as in the example below:

string basePath = @"c:\temp"; string filePath = "test.txt"; string combinedPath = Path.Combine(basePath, filePath); // produces c:\temp\test.txt 
+127
Jun 07 '09 at 11:04
source share

System.IO.Path.Combine () is what you need.

 Path.Combine(path1, path2); 
+25
Jun 07 '09 at 11:05
source share



All Articles