Jak połączyć dwie ścieżki w C#?

Jak połączyć dwie ścieżki plików w C#?

 87
Author: Peter Mortensen, 2009-06-07

2 answers

Musisz użyć ścieżki.Combine () jak w przykładzie poniżej:

string basePath = @"c:\temp";
string filePath = "test.txt";
string combinedPath = Path.Combine(basePath, filePath); 
// produces c:\temp\test.txt
 138
Author: Jose Basilio,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2009-06-07 11:04:33

System. IO.Path. Combine() jest tym, czego potrzebujesz.

Path.Combine(path1, path2);
 29
Author: Cameron MacFarland,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2009-06-07 11:05:24