我試圖在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應用程序凍結了一會兒,然後關閉。代碼有問題嗎?任何想法是怎麼回事? 在此先感謝
執行此操作:Project - > Properties - > Debug。在「調試器類型」下更改爲「混合」。這應該阻止應用程序因拋出異常而關閉,從而允許您檢查它。 – Draco18s
@Draco18s的建議我很好。另外,請檢查Hololens Device Portal是否已成功創建此文件。還捕獲崩潰轉儲,參考:https://developer.microsoft.com/en-us/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 –