parse_path()
剖析檔案路徑 string
,並傳回 dynamic
物件,其中包含下列路徑部分:
- 配置
- RootPath
- DirectoryPath
- DirectoryName
- 檔案名稱
- 延伸模組
- AlternateDataStreamName
除了這兩種斜線類型的簡單路徑之外,函式還支援具有下列項目的路徑:
- 結構描述。 例如,"file://..."
- 共用路徑。 例如,"\shareddrive\users..."
- 完整路徑。 例如,"\?\C:...""
- 替代資料流。 例如,"file1.exe:file2.exe"
語法
parse_path(
path)
深入瞭解 語法慣例。
參數
名稱 | 類型 | 必要 | Description |
---|---|---|---|
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":""} |
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應