GetPathRoot

百科

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:\'

标签:
声明:此文信息来源于网络,登载此文只为提供信息参考,并不用于任何商业目的。如有侵权,请及时联系我们:yongganaa@126.com

评论留言

我要留言

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

声明:此文信息来源于网络,登载此文只为提供信息参考,并不用于任何商业目的。如有侵权,请及时联系我们:yongganaa@126.com