使用HoloLens2模拟器时,我能够成功地将.csv文件生成到桌面路径(例如C:\Users\name\ desktop );但是,当我使用该路径(如在Windows上显示) U:\Users\name\Documents时,会出现DirectoryNotFoundException错误。
错误:
DirectoryNotFoundException:找不到路径"U:\Users\name\Documents\rWrist.csv“的一部分。在System.IO.FileStream..ctor (System.String path,System.IO.FileMode模式,System.IO.FileAccess access,System.IO.FileShare共享,System.Int32 bufferSize,System.Boolean匿名,System.IO.FileOptions选项) 0x00000 in <00000000000000000000000000000000>:0
代码:
string basePath = @"U:\Users\name\Documents\";
foreach (var getSave in getDictionary)
{
string saveLocation = $"{basePath}{getSave.Key}.csv";
File.WriteAllText(saveLocation, null);
using (StreamWriter sw = new StreamWriter(saveLocation))
{
sw.WriteLine("{0},{1},{2},{3}", "Time", "xPos", "yPos", "zPos");
foreach (var kvp in getSave.Value)
{
sw.WriteLine("{0},{1},{2},{3}", kvp.Key, kvp.Value.x, kvp.Value.y, kvp.Value.z);
}
}
}任何帮助都将不胜感激!
发布于 2022-02-04 13:51:40
出现在Windows设备门户上的路径不能直接访问。据我所知,它们都是内部的。
您可以使用Application.persistentDataPath来存储数据。
然后将其保存到“用户文件夹\LocalAppData\ProjectName\LocalState\.”,如Windows所示。
https://stackoverflow.com/questions/70981926
复制相似问题