Hello,
until now I was using the Binaryformatter but that did not work with Unity UWP so I switched to XML.
I have a List with a struct in it and want to save it to a file to load it next App start on my hololens.
I do not care where the file is, just want to save and load it.
The saving does not seem to work on the hololens (release build).
I tried LocalFolder and RoamingFolder, both do not work.
Where or how can I save my List?
Thanks a lot for your help!
Code:
public static void SaveQRList(string nameList)
{
try
{
#if WINDOWS_UWP
//StorageFolder storageFolder = ApplicationData.Current.LocalFolder;
StorageFolder storageFolder = ApplicationData.Current.RoamingFolder;
nameList = storageFolder + "\\" + nameList;
#endif
//Speichern
Stream stream = File.Open(nameList, FileMode.Create);
//BinaryFormatter writer = new BinaryFormatter();
XmlSerializer writer = new XmlSerializer(QRCodesList.GetType());
Debug.Log("Writing Containers");
writer.Serialize(stream, QRCodesList);
//stream.Close();
Debug.Log("Write CodeList finished");
}
catch (System.Exception ex)
{
Debug.LogError("Save CodeList List Error: " + ex.ToString());
}
}
Error when saving:
âLR Worlds.exeâ (CoreCLR: CoreCLR_UWP_Domain): Loaded âC:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LRWorldsVS.Release_x86.beh\System.Xml.XmlSerializer.dllâ. Cannot find or open the PDB file.
âLR Worlds.exeâ (CoreCLR: CoreCLR_UWP_Domain): Loaded âC:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LRWorldsVS.Release_x86.beh\System.Resources.ResourceManager.dllâ. Module was built without symbols.
Exception thrown: âSystem.IO.DirectoryNotFoundExceptionâ in System.IO.FileSystem.dll
Save CodeList List Error: System.IO.DirectoryNotFoundException: Could not find a part of the path âC:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LRWorldsVS.Release_x86.beh\Windows.Storage.StorageFolder\QRCodesList.serâ.
at System.IO.Win32FileStream.Init(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs)
at System.IO.Win32FileSystem.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, FileStream parent)
at System.IO.MultiplexingWin32WinRTFileSystem.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, FileStream parent)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at Globals.SaveQRList(String nameList)