
GetPathRoot的用途是用来获取指定路径的根目录信息。例如C语言中:string path = @"\mydir\";string fileName = "myfile.ext";string 占半主帝电fullPath = @"C:\mydir\myfile.ext";string pathRoot。
- 外文名称 GetPathRoot
- 分类 编程语言函数
用途
获取指定路径的根目录信息。
c#举例
string path = @"\mydir\";
string fil宣裂联球买环eName = "myf来自ile.ext";
string fullPath = @"C:\mydir\myfile.ext";
string pathRoot;
pathRoot = Path.GetPathRoot(path);
Console.WriteLine("GetPathRoot('{0}') returns '{1}'", path, pathRoot);
pathRoot = Path.GetPathRoot(fileNa审杨纸的诉志压历剂me);
Cons七雷态甚低认开ole.WriteLine("GetPathRoot360百科('{0}') retur细鲁效相逐ns '{1}'", fileName, pathRoot);
pathRo办技ot = Path.GetPathRoot(fullPath);
Console.WriteLine("G什极己更很促米李胞被宣etPathRoot('{0}') returns '{1}'", fullPath, p苏单千角临略渐击athRoot);
// This code produces output similar to the following:
//
// GetPat修氢hRoot('\mydi育套破饭致四对战控夜特r\') returns '\'
// G航印层诗候斯义etPathRoot('myfile.ext') returns ''
// GetPathRoot('C:\mydir\myfi不九视钢宁象买le.ext') returns 'C:\'
评论留言