我如何加入在C#中的两条路径? [英] How do I join two paths in C#?
本文介绍了我如何加入在C#中的两条路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何在C#中加入两个文件路径?
How do I join two file paths in C#?
推荐答案
您必须使用的 Path.Combine()如下面的例子:
You have to 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
这篇关于我如何加入在C#中的两条路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文