将文件存放在HoloLens2 上,然后读取本机文件,需要使用异步方法。
HoloLens2的文件存放在Windows.Storage.ApplicationData.Current.LocalFolder下
#if WINDOWS_UWP
public async void FileProcessor()//异步方法
{
Windows.Storage.StorageFolder WriteFolder = Windows.Storage.ApplicationData.Current.LocalFolder;
if(firstSave)
{
StorageFile sampleFile = await WriteFolder.CreateFileAsync(fileName, CreationCollisionOption.ReplaceExisting);
await FileIO.WriteTextAsync(sampleFile,saveInformation+"\r\n");
firstSave=false;
}
else{
StorageFile sampleFile = await WriteFolder.CreateFileAsync(fileName, CreationCollisionOption.OpenIfExists);
await FileIO.WriteTextAsync(sampleFile,saveInformation+"\r\n");
}
}
#endif