【问题标题】:How to move files from one directory to another in Unity Hololens如何在 Unity Hololens 中将文件从一个目录移动到另一个目录
【发布时间】:2019-10-12 10:51:05
【问题描述】:

here is picture of the code

我正在尝试使用 windows.storage 命名空间并尝试将文件统一放入流式资产中。

【问题讨论】:

  • 对不起,we can't accept images of code or errors。请edit您的问题并将其作为文本包含在内,以便我们可以尝试重现问题而无需重新输入所有内容,并且屏幕阅读器可以正确索引或阅读您的问题。
  • 始终在 UWP 设备上使用 FileStream 并传入正确的打开方法和文件共享选项。 Windows 系统在 FileIO 方面非常挑剔

标签: c# unity3d directory hololens


【解决方案1】:

Unity StreamingAssets 文件夹是只读的,用于存储资产。具体说明请参见Unity官方文档:Application.StreamingAssetsPath

因此,建议你把文件保存在Application.persistentDataPath,注意源文件有读写权限。

要将文件从 objects3D 文件夹移动到 persistentDataPath 文件夹,您可以尝试以下代码:

#if ENABLE_WINMD_SUPPORT
        var objectPath = KnownFolders.Objects3D.Path;
        string path = Path.Combine(objectPath, "MyFile.txt");
        string targetPath = Path.Combine(Application.persistentDataPath, "MyFile.txt");
        using (TextWriter writer = File.CreateText(path))
        {
            writer.WriteLine("test");
        }
        File.Move( path, targetPath);
#endif

【讨论】:

    猜你喜欢
    • 2019-09-26
    • 2017-07-20
    • 2014-05-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-04
    相关资源
    最近更新 更多