문제

다음과 같이 통과 할 때 인수가 분리 될 때 이것을 처리 할 수있는 또 다른 방법이 있는지 궁금합니다.

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();

그런 다음 환경에 액세스 할 때 새 응용 프로그램에서 GetCommandLinesargs () 우리는 다음과 같은 모습을 얻는 배열을 얻습니다.

string[] arr = {"filename","c:\dir1","dir2","dir3", "file1.txt"}
도움이 되었습니까?

해결책

문제는 논증을 올바르게 전달하지 않는다는 것입니다.

다음과 같이 경로 주위에 인용문을 포함해야합니다.

psi.Arguments = @"""c:\dir1\dir2\dir3\file1.txt""";
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top