[英]How to move files from one directory to another in Unity Hololens
here is picture of the code这是代码的图片
I am trying to use windows.storage namespace and trying to drop a file in Streaming asset in unity.我正在尝试使用 windows.storage 命名空间并尝试将文件统一放在流式资产中。
The Unity StreamingAssets folder is read-only and used to store Assets. Unity StreamingAssets 文件夹是只读的,用于存储资产。 For specific instructions, please see the Unity official doc: Application.StreamingAssetsPath .
具体说明请参见 Unity 官方文档: Application.StreamingAssetsPath 。
Therefore, I suggest you save the file in the Application.persistentDataPath and note that source files have read and write permissions.因此,我建议您将文件保存在Application.persistentDataPath中,并注意源文件具有读写权限。
To move the file from the objects3D folder to the persistentDataPath folder, you can try the following code:要将文件从 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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.