加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

文件路径及文件名字符串截取替换操作方法

发布时间:2020-12-15 17:59:22 所属栏目:百科 来源:网络整理
导读:今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 string filePath = @"E:Randy0528中文目录JustTest.rar"; Response.Write("文件路径:"+filePath); Response.Write("br/更改路径字符串的扩展名。b

以下代码由PHP站长网 52php.cn收集自互联网

现在PHP站长网小编把它分享给大家,仅供参考

    string filePath = @"E:Randy0528中文目录JustTest.rar";  
    Response.Write("文件路径:"+filePath);  
    Response.Write("<br/>更改路径字符串的扩展名。<br/>");  
    Response.Write(System.IO.Path.ChangeExtension(filePath,"txt"));  
    Response.Write("<br/>返回指定路径字符串的目录信息。。<br/>");  
    Response.Write(System.IO.Path.GetDirectoryName(filePath));  
    Response.Write("<br/>返回指定的路径字符串的扩展名。<br/>");  
    Response.Write(System.IO.Path.GetExtension(filePath));  
    Response.Write("<br/>返回指定路径字符串的文件名和扩展名。<br/>");  
    Response.Write(System.IO.Path.GetFileName(filePath));  
    Response.Write("<br/>返回不具有扩展名的指定路径字符串的文件名。<br/>");  
    Response.Write(System.IO.Path.GetFileNameWithoutExtension(filePath));  
    Response.Write("<br/>获取指定路径的根目录信息。<br/>");  
    Response.Write(System.IO.Path.GetPathRoot(filePath));  
    Response.Write("<br/>返回随机文件夹名或文件名。<br/>");  
    Response.Write(System.IO.Path.GetRandomFileName());  
    Response.Write("<br/>创建磁盘上唯一命名的零字节的临时文件并返回该文件的完整路径。<br/>");  
    Response.Write(System.IO.Path.GetTempFileName());  
    Response.Write("<br/>返回当前系统的临时文件夹的路径。<br/>");  
    Response.Write(System.IO.Path.GetTempPath());  
    Response.Write("<br/>确定路径是否包括文件扩展名。<br/>");  
    Response.Write(System.IO.Path.HasExtension(filePath));  
    Response.Write("<br/>获取一个值,该值指示指定的路径字符串是包含绝对路径信息还是包含相对路径信息。<br/>");  
    Response.Write(System.IO.Path.IsPathRooted(filePath));  

以上内容由PHP站长网【52php.cn】收集整理供大家参考研究

如果以上内容对您有帮助,欢迎收藏、点赞、推荐、分享。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读