另类的Environment.GetCommandLineArgs()
-
20-09-2019 - |
题
只是想知道如果有另一种方式来处理此为参数越来越分裂传递这样当:
System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(fileName);
psi.Arguments = @"c:\dir1\dir2\dir3\file1.txt";
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo = psi;
p.Start();
然后,在当我们访问Environment.GetCommandLinesARgs新的应用程序() 我们得到的阵列看起来像这样:
string[] arr = {"filename","c:\dir1","dir2","dir3", "file1.txt"}
解决方案
的问题是,您没有传递的参数在正常。
您需要包括路径周围的引号,像这样的:
psi.Arguments = @"""c:\dir1\dir2\dir3\file1.txt""";
不隶属于 StackOverflow