简体   繁体   中英

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.

The Unity StreamingAssets folder is read-only and used to store Assets. For specific instructions, please see the Unity official doc: Application.StreamingAssetsPath .

Therefore, I suggest you save the file in the Application.persistentDataPath and note that source files have read and write permissions.

To move the file from the objects3D folder to the persistentDataPath folder, you can try the following code:

#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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM