2012-12-04 2 views
0

나는 wpf 응용 프로그램을 개발 중입니다. 다음 코드를 사용하여 degrib.exe를 실행합니다.exe가 프로그램 파일에서 실행되지 않는 이유는 무엇입니까?

public static void GenerateCsvFile(string fileName) 
     { 
      try 
      { 
       MessageBox.Show("Csv Error"); 
       MessageBox.Show("File Name : " + fileName); 
       MessageBox.Show("WorkingDirectory" + new FileInfo(fileName).DirectoryName); 

       System.Diagnostics.Process process = new System.Diagnostics.Process(); 
       System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(); 
       startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; 
       startInfo.FileName = @"C:\ndfd\degrib\bin\degrib.exe"; 
       startInfo.Arguments = @"" + fileName + "" + " -C -msg 1 -Csv"; 
       startInfo.UseShellExecute = true; 
       startInfo.WorkingDirectory = new FileInfo(fileName).DirectoryName; 
       process.StartInfo = startInfo; 
       process.Start(); 
       process.WaitForExit(); 
       process.Close(); 

       System.Diagnostics.Process process1 = new System.Diagnostics.Process(); 
       System.Diagnostics.ProcessStartInfo startInfo1 = new System.Diagnostics.ProcessStartInfo(); 
       startInfo1.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; 
       startInfo1.FileName = @"C:\ndfd\degrib\bin\degrib.exe"; 
       startInfo1.Arguments = @"" + fileName + "" + " -C -msg all -nMet -Csv"; 
       startInfo1.UseShellExecute = true; 
       startInfo1.WorkingDirectory = new FileInfo(fileName).DirectoryName; 
       process1.StartInfo = startInfo1; 
       process1.Start(); 
       process1.WaitForExit(); 
       process1.Close(); 
      } 
      catch (Exception ex) 
      { 
       MessageBox.Show("Degrib Error"); 
       Utility.ShowErrorMessage(ex); 
      } 
     } 

degrib.exe는 grib 파일에서 csv 파일을 생성합니다. 여기 http://www.nws.noaa.gov/mdl/degrib/index.php은 degrib의 설명입니다. 위의 함수에서 fileName은 grib 파일의 경로입니다. 위의 함수는 grib 파일이 Program Files 이외의 다른 폴더에 있으면 csv 파일을 grib 파일에서 크롤링합니다. 프로그램 파일이나 프로그램 파일의 다른 폴더에 grib 파일을 놓은 경우 동일한 기능이 csv 파일을 생성하지 않습니다. 동일한 기능이 AppData 폴더에서도 작동하지 않습니다. 왜 이런 일이 일어나는거야? 위 문제에 대한 해결책을 제공해 주시겠습니까?

+0

사용자 권한. 프로세스를 관리자로 실행하십시오. – leppie

+0

당신은 degrib을 쓴 사람에게이 질문을해야합니다. – Tigran

+2

@leppie : AppData는 제 이해에서 관리자 권한이없는 경우에도 작동해야합니다. – Tigran

답변

0

(기본값 : Vista 또는 Win7)은 상승 액세스로 시작하지 않는 한 응용 프로그램에 프로그램 쓰기 권한을 부여하지 않습니다. 당신은 추가하여이 작업을 수행 할 수 있습니다 : 그러나

startInfo.Verb = "runas"; 

를,이 입력 및 출력 매개 변수를 사용할 내가 나타났습니다 degrib 설명서를 읽고. 귀하의 경우에는 생성 된 CSV 파일에 대해 미리 정의 된 위치를 사용하는 것이 좋습니다. http://www.nws.noaa.gov/mdl/degrib/txtview.php?file=degrib.txt&dir=base

-in [File] 
    You can provide the file to read the GRIB message from either: 
    1) right after "degrib", 
    2) using the "-in [File]" option, 
    3) on standard input. 
    -out [File] 
     Name of the file to store the results. Must have 1 and only 1 dot in 
     the name, and the extension must be 3 characters. The extension will 
     be replaced depending on file format. 
    -namePath [Path] 
     Name of a directory to put the files in. 
     Only applicable if -out is NOT Specified. 
+0

os로 windows xp를 가지고 있습니다 –

+0

Windows XP는 권한 편집이 기본적으로 숨겨져 있다는 점을 제외하면 비슷한 동작을합니다. 도구> 폴더 옵션> "간단한 파일 공유 사용 [권장]"을보고 선택 해제하십시오. WPF 앱에 쓰기 권한이 있는지 확인하십시오. – ClotzA

+0

"간단한 파일 공유 사용 [권장]"을 선택하지 않았습니다. 내 WPF 앱에 쓰기 권한이 있습니다. 응용 프로그램 데이터 폴더의 다른 파일에 대한 쓰기 작업을 성공적으로 수행하고 있습니다. Application Data 폴더에서 필요한 모든 기능을 수행 할 수 있습니다. 위의 함수를 사용하여 grib 파일을 디그리브 할 수만 있습니다. –

관련 문제