你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

parse_path()

分析文件路径 string,并返回包含该路径的以下部分的 dynamic 对象:

  • Scheme
  • RootPath
  • DirectoryPath
  • DirectoryName
  • 文件名
  • 分机
  • AlternateDataStreamName

除了具有两种斜杠类型的简单路径外,此函数还支持包含以下内容的路径:

  • 架构。 例如,“file://...”
  • 共享路径。 例如,“\shareddrive\users...”
  • 长路径。 例如,“\?\C:..."”
  • 备用数据流。 例如,“file1.exe:file2.exe”

语法

parse_path(path)

详细了解语法约定

参数

名称 类型 必需 说明
路径 string ✔️ 文件路径。

返回

包含上面列出的路径组件的 dynamic 类型的对象。

示例

datatable(p:string) 
[
    @"C:\temp\file.txt",
    @"temp\file.txt",
    "file://C:/temp/file.txt:some.exe",
    @"\\shared\users\temp\file.txt.gz",
    "/usr/lib/temp/file.txt"
]
| extend path_parts = parse_path(p)

输出

p path_parts
C:\temp\file.txt {"Scheme":"","RootPath":"C:","DirectoryPath":"C:\temp","DirectoryName":"temp","Filename":"file.txt","Extension":"txt","AlternateDataStreamName":""}
temp\file.txt {"Scheme":"","RootPath":"","DirectoryPath":"temp","DirectoryName":"temp","Filename":"file.txt","Extension":"txt","AlternateDataStreamName":""}
file://C:/temp/file.txt:some.exe {"Scheme":"file","RootPath":"C:","DirectoryPath":"C:/temp","DirectoryName":"temp","Filename":"file.txt","Extension":"txt","AlternateDataStreamName":"some.exe"}
\shared\users\temp\file.txt.gz {"Scheme":"","RootPath":"","DirectoryPath":"\\shared\users\temp","DirectoryName":"temp","Filename":"file.txt.gz","Extension":"gz","AlternateDataStreamName":""}
/usr/lib/temp/file.txt {"Scheme":"","RootPath":"","DirectoryPath":"/usr/lib/temp","DirectoryName":"temp","Filename":"file.txt","Extension":"txt","AlternateDataStreamName":""}