C# 路径拼接(将多个字符串组合成一个路径)


        C#将多个字符串组合成一个路径,可利用System.IO.Path类中的Combine(String,String)方法。


        命名空间为:using System.IO;


示例:

            string path1 = @"D:\temp";
            string path2 = "result.txt";
            string newPath = Path.Combine(path1, path2); // newPath = "D:\temp\result.txt";


System_CAPS_pubmethodSystem_CAPS_static Combine(String, String)

将两个字符串组合成一个路径。

System_CAPS_pubmethodSystem_CAPS_static Combine(String, String, String)

将三个字符串组合成一个路径。

System_CAPS_pubmethodSystem_CAPS_static Combine(String, String, String, String)

将四个字符串组合成一个路径。

System_CAPS_pubmethodSystem_CAPS_static Combine(String[])

将字符串数组组合成一个路径。


        参考资料: MSDN:Path 类

你可能感兴趣的:(C#)