Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/unity3d/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在my hololens的Streamingassets中编辑XML文件_C#_Unity3d_Vuforia_Hololens - Fatal编程技术网

C# 如何在my hololens的Streamingassets中编辑XML文件

C# 如何在my hololens的Streamingassets中编辑XML文件,c#,unity3d,vuforia,hololens,C#,Unity3d,Vuforia,Hololens,我的应用程序有一个非常令人沮丧的问题,我正在使用Vuforia,我正在尝试从运行时在streamingassets中编辑和保存xml,但是,我遇到以下异常:Unauthorizedaccessexception。。。对路径的访问被拒绝 我试图通过简单地使用将XMLDocument保存到路径来保存这两个文件,这是我得到Unauthorizedaccessexception的地方,但也尝试了Windows.Storage命名空间,在这里我得到一个异常,说我的路径无效 这里我得到了Unauthoriz

我的应用程序有一个非常令人沮丧的问题,我正在使用Vuforia,我正在尝试从运行时在streamingassets中编辑和保存xml,但是,我遇到以下异常:Unauthorizedaccessexception。。。对路径的访问被拒绝

我试图通过简单地使用将XMLDocument保存到路径来保存这两个文件,这是我得到Unauthorizedaccessexception的地方,但也尝试了Windows.Storage命名空间,在这里我得到一个异常,说我的路径无效

这里我得到了Unauthorizedaccessexception:

xmlDoc.Save(path);
这里我得到的路径是无效的

var folderPath = Path.Combine(Application.streamingAssetsPath, "Vuforia");
StorageFolder folder = await StorageFolder.GetFolderFromPathAsync(folderPath);
StorageFile textFile = await folder.GetFileAsync("Warehouse.xml");
await FileIO.WriteTextAsync(textFile, str);

使用
var folderPath=Path.Combine(Application.persistentDataPath)
使用
xmlDoc.save(路径)保存文件工作正常。但我不能这样做,因为Vuforia只能访问StreamingAssets中的图像目标(对吗?)。那么,有没有人知道我做错了什么,我该怎么做才能访问StreamingAssets文件夹,或者更改Vuforia使用的文件夹的位置?

在HoloLens上,我也遇到了问题

你可能更愿意尝试结合使用

在我看来,全息透镜需要
文件。用和打开

我还建议使用

差不多

var filePath = Path.Combine(Application.streamAssetsPath, "Vuforia", "Warehouse.xml");

using(var fileStream = File.Open(filePath, FileMode.Open, FileAccess.Write, FileShare.Write)) 
{
    using (var writer = new StreamWritet(fileStream))
    {
        await writer.WriteAsync(textFile);
    }
}
这在过去通常对我有效


但是请注意,我从来没有尝试从构建中写入
StreamingAssetPath
,只在编辑器脚本中的UnityEditor中写入。而在构建中,只有持久数据路径流媒体资产在内置应用程序中可能是只读的。



在智能手机上输入,所以没有保修,但我希望这个想法变得清晰起来

你在安卓系统上吗?不,我正在部署hololensStreamingAssets是只读的。因此,您必须将文件复制到persistentDataPath下的某个位置。谢谢你的回答!但是,我使用了您建议的代码,但仍然得到Unauthorizedaccessexception。有没有其他方法可以修改对文件的访问?正如我所说的,我不确定是否可以在内置应用程序中写入streamingassets。可能在生成后变为只读。