admin管理员组

文章数量:1536457

2024年1月27日发(作者:)

using stics;using ;using tion;public class Example{public static void Main(string[] args){ine($"Current directory is '{tDirectory}'");ine("Setting current directory to 'C:'");rentDirectory(@"C:");string path = lPath(@"D:FY2018");ine($"'D:FY2018' resolves to {path}");path = lPath(@"D:FY2018");ine($"'D:FY2018' resolves to {path}");ine("Setting current directory to 'D:Docs'");rentDirectory(@"D:Docs");path = lPath(@"D:FY2018");ine($"'D:FY2018' resolves to {path}");path = lPath(@"D:FY2018");// This will be "D:DocsFY2018" as it happens to match the drive of the current ine($"'D:FY2018' resolves to {path}");ine("Setting current directory to 'C:'");rentDirectory(@"C:");path = lPath(@"D:FY2018");ine($"'D:FY2018' resolves to {path}");// This will be either "D:FY2018" or "D:FY2018FY2018" in the subprocess. In the sub process,// the command prompt set the current directory before launch of our application, which// sets a hidden environment variable that is = lPath(@"D:FY2018");ine($"'D:FY2018' resolves to {path}");if ( < 1){ine(@"Launching again, after setting current directory to D:FY2018");Uri currentExe = new Uri(cutingAssembly().GetName().CodeBase, te);

string commandLine = $"/C cd D:FY2018 & "{ath}" stop";ProcessStartInfo psi = new ProcessStartInfo("cmd", commandLine); ;(psi).WaitForExit();ine("Sub process returned:");path = lPath(@"D:FY2018");ine($"'D:FY2018' resolves to {path}");path = lPath(@"D:FY2018");ine($"'D:FY2018' resolves to {path}");}ine("Press any key ");y();}}// The example displays the following output:// Current directory is 'C:Programsfile-paths'// Setting current directory to 'C:'// 'D:FY2018' resolves to D:FY2018// 'D:FY2018' resolves to d:FY2018// Setting current directory to 'D:Docs'// 'D:FY2018' resolves to D:FY2018// 'D:FY2018' resolves to D:DocsFY2018// Setting current directory to 'C:'// 'D:FY2018' resolves to D:FY2018// 'D:FY2018' resolves to d:FY2018// Launching again, after setting current directory to D:FY2018// Sub process returned:// 'D:FY2018' resolves to D:FY2018// 'D:FY2018' resolves to d:FY2018// The subprocess displays the following output:// Current directory is 'C:'// Setting current directory to 'C:'// 'D:FY2018' resolves to D:FY2018// 'D:FY2018' resolves to D:FY2018FY2018// Setting current directory to 'D:Docs'

// 'D:FY2018' resolves to D:FY2018// 'D:FY2018' resolves to D:DocsFY2018// Setting current directory to 'C:'// 'D:FY2018' resolves to D:FY2018// 'D:FY2018' resolves to D:FY2018FY2018Imports sticsImports rts tionPublic Module ExamplePublic Sub Main(args() As String)ine($"Current directory is '{tDirectory}'")ine("Setting current directory to 'C:'")rentDirectory("C:")Dim filePath As String = lPath("D:FY2018")ine($"'D:FY2018' resolves to {filePath}")filePath = lPath("D:FY2018")ine($"'D:FY2018' resolves to {filePath}")ine("Setting current directory to 'D:Docs'")rentDirectory("D:Docs")filePath = lPath("D:FY2018")ine($"'D:FY2018' resolves to {filePath}")filePath = lPath("D:FY2018")' This will be "D:DocsFY2018" as it happens to match the drive of the current ine($"'D:FY2018' resolves to {filePath}")ine("Setting current directory to 'C:'")rentDirectory("C:")filePath = lPath("D:FY2018")ine($"'D:FY2018' resolves to {filePath}")' This will be either "D:FY2018" or "D:FY2018FY2018" in the subprocess. In the sub process,' the command prompt set the current directory before launch of our application, which' sets a hidden environment variable that is th = lPath("D:FY2018")ine($"'D:FY2018' resolves to {filePath}")If < 1 ine("Launching again, after setting current directory to D:FY2018")

Dim currentExe As New Uri(cutingAssembly().GetName().CodeBase, te)Dim commandLine As String = $"/C cd D:FY2018 & ""{ath}"" stop"Dim psi As New ProcessStartInfo("cmd", commandLine)(psi).WaitForExit()ine("Sub process returned:")filePath = lPath("D:FY2018")ine($"'D:FY2018' resolves to {filePath}")filePath = lPath("D:FY2018")ine($"'D:FY2018' resolves to {filePath}")End ine("Press any key ")y()End SubEnd Module' The example displays the following output:' Current directory is 'C:Programsfile-paths'' Setting current directory to 'C:'' 'D:FY2018' resolves to D:FY2018' 'D:FY2018' resolves to d:FY2018' Setting current directory to 'D:Docs'' 'D:FY2018' resolves to D:FY2018' 'D:FY2018' resolves to D:DocsFY2018' Setting current directory to 'C:'' 'D:FY2018' resolves to D:FY2018' 'D:FY2018' resolves to d:FY2018' Launching again, after setting current directory to D:FY2018' Sub process returned:' 'D:FY2018' resolves to D:FY2018' 'D:FY2018' resolves to d:FY2018' The subprocess displays the following output:' Current directory is 'C:'' Setting current directory to 'C:'' 'D:FY2018' resolves to D:FY2018' 'D:FY2018' resolves to D:FY2018FY2018

本文标签: 路径格式文件系统语言