.NET中Path类的几个方法(转载)

    技术2022-05-11  58

    来源:新浪博客  给大家介绍几个.NET中Path类的几个方法:  1. Path.combine(string, string)  根据给出的两个路径, 返回一个路径.  例如: string CompletePath = System.IO.Path.Combine(@"c:/MyApp", @"Images/skyline.jpg"); 将会返回一个全路径 c:/MyApp/Images/skyline.jpg 第一个参数中有无"/"结尾都可以.  2. Path.GetExtension(string) 返回给定文件路径的扩展名.例如: string FileExtention = System.IO.Path.GetExtention(@"C:/MyApp/Images/skyline.jpg"); 将会返回 "jpg"  3. Path.GetFileName(string) 给出文件名的全路径,返回文件名(包括扩展名).例如: string fileName = System.IO.Path.GetFileName(@"c:/MyApp/Images/skyline.jpg");

     

    最新回复(0)