2017-05-17 1 views
2

사용자로부터 입력을 기록하기 위해 텍스트 파일을 만들고 쓰는 hololens에 응용 프로그램을 만들려고합니다. 현재, 나는 파일을 만들고 파일 탐색기 또는 하나의 드라이브에서 액세스하려고 노력하고있다.hololens에 txt 파일 만들기

public void createFile() 
    { 
#if WINDOWS_UWP 
     Task task = new Task(
     async() => 
     { 
     testText.text="hi"; 
     StorageFolder storageFolder = ApplicationData.Current.LocalFolder; 
     StorageFile textFileForWrite = await storageFolder.CreateFileAsync("Myfile.txt"); 
     }); 
     task.Start(); 
     task.Wait(); 
#endif 
    } 

그것은 내가 여기 무엇을 기본적으로 다음과 같습니다 : https://forums.hololens.com/discussion/1862/how-to-deploy-and-read-data-file-with-app,하지만 난 그 방법을 실행하려고하면 조금 후 종료를 들어, hololens에 앱을 정지 이것은 내가 가지고있는 방법이다. 코드에 문제가 있습니까? 무슨 일이 일어나고 있는지 아십니까? 사전

유니티에서
+0

이렇게하십시오 : 프로젝트 -> 속성 -> 디버그. "Debugger Type"에서 "Mixed"로 변경하십시오. 그렇게하면 예외가 throw되어 응용 프로그램이 닫히지 않아서 응용 프로그램을 검사 할 수 있습니다. – Draco18s

+0

@ Draco18s 님의 제안은 훌륭합니다. 또한 Hololens Device Portal에서이 파일이 성공적으로 만들어 졌는지 확인하십시오. 또한 크래시 덤프 (https://developer.microsoft.com/ko-kr/windows/mixed-reality/using_the_windows_device_portal#file_explorer) 및 https://developer.microsoft.com/en-us/windows/mixed-reality를 캡처하십시오./using_the_windows_device_portal # app_crash_dumps –

답변

2

에서 감사합니다, 당신은 Application.persistentDataPath를 사용할 수 있습니다 장치 포털에서 https://docs.unity3d.com/ScriptReference/Application-persistentDataPath.html

/파일 탐색기, 그것은을 LocalAppData/YourApp/LocalState에 매핑됩니다. 아래 코드는 "MyFile.txt"라고 쓰고 있습니다.

using System.IO; 

string path = Path.Combine(Application.persistentDataPath, "MyFile.txt"); 
using (TextWriter writer = File.CreateText(path)) 
{ 
    // TODO write text here 
} 
+0

놀랍도록 유용하고 정확한 대답입니다. 대단히 감사합니다. – Dan