码迷,mamicode.com
首页 > 其他好文 > 详细

文件路径

时间:2018-01-22 21:19:07      阅读:133      评论:0      收藏:0      [点我收藏+]

标签:box   out   body   cto   post   tor   pre   file   sage   

string path = "C:\\dir1\\dir2\\foo.txt";
string str = "GetFullPath:" + Path.GetFullPath(path) + "\r\n";
str += "GetDirectoryName:" + Path.GetDirectoryName(path) + "\r\n";
str += "GetFileName:" + Path.GetFileName(path) + "\r\n";
str += "GetFileNameWithoutExtension:" + Path.GetFileNameWithoutExtension(path) + "\r\n";
str += "GetExtension:" + Path.GetExtension(path) + "\r\n";
str += "GetPathRoot:" + Path.GetPathRoot(path) + "\r\n";
MessageBox.Show(str);

结果: 
GetFullPath:C:\dir1\dir2\foo.txt
GetDirectoryName:C:\dir1\dir2
GetFileName:foo.txt
GetFileNameWithoutExtension:foo
GetExtension:.txt
GetPathRoot:C:\

 

文件路径

标签:box   out   body   cto   post   tor   pre   file   sage   

原文地址:https://www.cnblogs.com/siyunianhua/p/8331037.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!