当前位置: 首页 > 图文教程 > 网络编程 > ASP.NET > 介绍几个ASP.NET中容易忽略但却很重要的方法函数

ASP.NET
细细品味ASP.NET(一)
细细品味ASP.NET(二)
细细品味ASP.NET(三)
细细品味ASP.NET(四)
细细品味ASP.NET(五)
用asp.net和xml做的新闻更新系统(1)
用asp.net和xml做的新闻更新系统(2)
用asp.net和xml做的新闻更新系统(3)
十天学会ASP.net(1)
十天学会ASP.net(2)
十天学会ASP.net(3)
十天学会ASP.net(4)
十天学会ASP.net(5)
十天学会ASP.net(6)
十天学会ASP.net(7)
十天学会ASP.net(8)
十天学会ASP.net(9)
十天学会ASP.net(10)
ASP.NET创建XML Web服务全接触(1)
ASP.NET创建XML Web服务全接触(2)

介绍几个ASP.NET中容易忽略但却很重要的方法函数


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-11   浏览: 143 ::
收藏到网摘: n/a

给大家介绍几个.NET中Path类的几个方法:

1. Path.combine(string, string)
根据给出的两个路径, 返回一个路径.
例如:
string CompletePath = System.IO.Path.Combine(@"c:\MyApp", @"/upload/tech/20091011/20091011143312_f2fc990265c712c49d51a18a32b39f0c.jpg");
将会返回一个全路径 c:\MyApp\/upload/tech/20091011/20091011143312_f2fc990265c712c49d51a18a32b39f0c.jpg
第一个参数中有无"\"结尾都可以.

2. Path.GetExtension(string)
返回给定文件路径的扩展名.例如:
string FileExtention = System.IO.Path.GetExtention(@"C:\MyApp\/upload/tech/20091011/20091011143312_f2fc990265c712c49d51a18a32b39f0c.jpg");
将会返回 "jpg"

3. Path.GetFileName(string)
给出文件名的全路径,返回文件名(包括扩展名).例如:
string fileName = System.IO.Path.GetFileName(@"c:\MyApp\/upload/tech/20091011/20091011143312_f2fc990265c712c49d51a18a32b39f0c.jpg");
将会返回"/upload/tech/20091011/20091011143314_5ef698cd9fe650923ea331c15af3b160.jpg"