parse_path()

剖析檔案路徑 string ,並傳回 dynamic 包含下列路徑部分的物件:

  • 配置
  • RootPath
  • DirectoryPath
  • DirectoryName
  • FileName
  • 分機
  • AlternateDataStreamName

除了這兩種斜線的簡單路徑之外,函式還支援路徑與:

  • 結構描述。 例如,"file://..."
  • 共用路徑。 例如,"\shareddrive\users..."
  • 完整路徑。 例如,"\? \C: ..." "
  • 替代資料流。 例如,"file1.exe:file2.exe"

Syntax

parse_path(parse_path()

引數

  • 路徑:代表檔案路徑的字串。

傳回

型別的物件 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 {"配置": "","RootPath": "C:","DirectoryPath": "C:\temp","DirectoryName": "temp","Filename": "file.txt","Extension": "txt","AlternateDataStreamName": ""}
temp\file.txt {"配置": "","RootPath": "","DirectoryPath": "temp","DirectoryName": "temp","Filename": "file.txt","Extension": "txt","AlternateDataStreamName": ""}
file://C:/temp/file.txt:some.exe {"配置": "file","RootPath": "C:","DirectoryPath": "C:/temp","DirectoryName": "temp","Filename": "file.txt","Extension": "txt","AlternateDataStreamName": "some.exe"}
\shared\users\temp\file.txt. gz {"配置": "","RootPath": "","DirectoryPath": "\\shared\users\temp","DirectoryName": "temp","Filename": "file.txt. gz","Extension": "gz","AlternateDataStreamName": ""}
/usr/lib/temp/file.txt {"配置": "","RootPath": "","DirectoryPath": "/usr/lib/temp","DirectoryName": "temp","Filename": "file.txt","Extension": "txt","AlternateDataStreamName": ""}