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
版权声明:本文标题:c语言中文件路径格式,Windows系统中的文件路径格式 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dongtai/1706330781a177103.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论