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

来源:互联网 发布:jdk 8u60 linux x32 编辑:程序博客网 时间:2024/05/16 09:28


        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_staticCombine(String, String)

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

System_CAPS_pubmethodSystem_CAPS_staticCombine(String, String, String)

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

System_CAPS_pubmethodSystem_CAPS_staticCombine(String, String, String, String)

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

System_CAPS_pubmethodSystem_CAPS_staticCombine(String[])

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


        参考资料:MSDN:Path 类

0 0
原创粉丝点击