文件路径,文件名,扩展名 常用操作
string filePath = @"E:\Randy0528\中文目錄\JustTest.rar";
Response.Write("文件路徑:"+filePath);
Response.Write("<br/>更改路徑字符串的擴(kuò)展名。<br/>");
Response.Write(System.IO.Path.ChangeExtension(filePath, "txt"));
Response.Write("<br/>返回指定路徑字符串的目錄信息。。<br/>");
Response.Write(System.IO.Path.GetDirectoryName(filePath));
Response.Write("<br/>返回指定的路徑字符串的擴(kuò)展名。<br/>");
Response.Write(System.IO.Path.GetExtension(filePath));
Response.Write("<br/>返回指定路徑字符串的文件名和擴(kuò)展名。<br/>");
Response.Write(System.IO.Path.GetFileName(filePath));
Response.Write("<br/>返回不具有擴(kuò)展名的指定路徑字符串的文件名。<br/>");
Response.Write(System.IO.Path.GetFileNameWithoutExtension(filePath));
Response.Write("<br/>獲取指定路徑的根目錄信息。<br/>");
Response.Write(System.IO.Path.GetPathRoot(filePath));
Response.Write("<br/>返回隨機(jī)文件夾名或文件名。<br/>");
Response.Write(System.IO.Path.GetRandomFileName());
Response.Write("<br/>創(chuàng)建磁盤上唯一命名的零字節(jié)的臨時文件并返回該文件的完整路徑。<br/>");
Response.Write(System.IO.Path.GetTempFileName());
Response.Write("<br/>返回當(dāng)前系統(tǒng)的臨時文件夾的路徑。<br/>");
Response.Write(System.IO.Path.GetTempPath());
Response.Write("<br/>確定路徑是否包括文件擴(kuò)展名。<br/>");
Response.Write(System.IO.Path.HasExtension(filePath));
Response.Write("<br/>獲取一個值,該值指示指定的路徑字符串是包含絕對路徑信息還是包含相對路徑信息。<br/>");
Response.Write(System.IO.Path.IsPathRooted(filePath));
轉(zhuǎn)載于:https://www.cnblogs.com/TivonStone/archive/2012/12/07/2806878.html
總結(jié)
以上是生活随笔為你收集整理的文件路径,文件名,扩展名 常用操作的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Sencha Touch 笔记
- 下一篇: 【转载】RHEL系统crontab计划任