2013-10-05 1 views
0

텍스트 편집기 응용 프로그램에서 파일 실행을 처리하려고합니다.Windows Store/WinJS 응용 프로그램에서 파일 활성화를 처리하는 방법

http://msdn.microsoft.com/en-us/library/windows/apps/hh452684.aspx

불행하게도,이 파일을 수신 지점에서 정지 및 파일 말했다 방법을 실제로 개방에 어떤 정보를 제공하지 않습니다 : 마이크로 소프트는 여기에이 작업을 수행하는 방법의 샘플을 가지고있다.

나는 성공적으로 활성화 된 이벤트를 처리 할 수있는, 내가 파일에 대한 절대 경로로 끝날. 예 :

메트로 앱에는 특정 조건을 제외하고는 절대 경로에 대한 액세스 권한이 없습니다.

  1. 앱 전에 파일을 액세스 한 경우 파일이 파일 선택기
  2. 통해 사용자에 의해 선택되고, 앱인지 경로가 Windows.Storage.AccessCache
  3. 에 저장되었는지 파일을 실행으로 전달합니다.

이 경우 숫자 3이 적용되지만 파일을 열 수 없습니다.

내가 Windows.Storage.StorageFile.getFileFromPathAsync(path_to_file) 시도했다하지만 난이 오류 이미 TXT 파일을 받아 들일 매니페스트 내 응용 프로그램 패키지를 설정 한

0x80070005 - JavaScript runtime error: Access is denied. 

WinRT information: Cannot access the specified file or folder (඀6). 
The item is not in a location that the application has access to (including 
application data folders, folders that are accessible via capabilities 
and persisted items in the StorageApplicationPermissions lists). Verify 
that the file is not marked with system or hidden file attributes. 

를 얻을.

답변

2

StorageFile 또는 StorageFileWebUIFileActivatedEventArgs 인수로 앱에 전달됩니다. 이 시도 :

app.onactivated = function (args) { 
    if (args.detail.kind === activation.ActivationKind.file) { 
     if (args.detail.files.size > 0) { 
      var storageFile = args.detail.files[0]; 
      Windows.Storage.FileIO.readTextAsync(storageFile).then(function (text) { 
       // Do something with the content of the file. 
      }); 
     } 
    } 

    // ... 
} 
+0

도이을! 이제는 분명해 보입니다. 그게 완벽하게 작동합니다, 고마워요! – roryok

관련 문제