locked
RoamingFolder, OneDrive, and Testing/Debugging

    Question

  • I am attempting to use ApplicationData.Current.RoamingFolder to store my app's data. My current code for saving & loading the data is as follows:
    <Extension()> Public Sub Save(ByRef recipients As List(Of Recipient))
    	Dim tempfiletask As Task(Of StorageFile) = ApplicationData.Current.RoamingFolder.CreateFileAsync("Recipients.xml", CreationCollisionOption.ReplaceExisting).AsTask()
    	Dim xml As New XmlSerializer(GetType(Recipient()), New XmlRootAttribute("Recipients"))
    	Using sw As New StringWriter()
    		xml.Serialize(sw, recipients.ToArray())
    		tempfiletask.Wait()
    		FileIO.WriteTextAsync(tempfiletask.Result, sw.ToString()).AsTask().Wait()
    	End Using
    End Sub
    
    <Extension()> Public Sub Load(ByRef recipients As List(Of Recipient))
    	Try
    		Dim tempfiletask As Task(Of StorageFile) = ApplicationData.Current.RoamingFolder.GetFileAsync("Recipients.xml").AsTask()
    		tempfiletask.Wait()
    		Dim readtexttask As Task(Of String) = FileIO.ReadTextAsync(tempfiletask.Result).AsTask()
    		readtexttask.Wait()
    		recipients = CType(New XmlSerializer(GetType(Recipient()), New XmlRootAttribute("Recipients")).Deserialize(New StringReader(readtexttask.Result)), Recipient()).ToList()
    	Catch aggregateex As AggregateException : recipients = New List(Of Recipient)
    	Catch ex As Exception : recipients = New List(Of Recipient)
    	End Try
    End Sub
    This worked fine when I used LocalFolder instead of RoamingFolder, but I cannot seem to get it to work with this code. I would have expected to see the file (in this case, Recipients.xml) in OneDrive, but I am not seeing that even though I added my Microsoft Account info in the Emulator. Does Visual Studio 2013's Emulator provide any way to test code that uses the RoamingFolder property? Is there something wrong with my code (because it seemed to work fine when I used LocalFolder)? Thanks.

    Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/

    Monday, December 15, 2014 5:03 PM

Answers

  • Roaming folders do not roam to OneDrive at all.  Is there documentation that says otherwise?


    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Tuesday, December 16, 2014 12:57 PM
    Moderator

All replies

  • How long are you giving before expecting to see it in OneDrive?

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Monday, December 15, 2014 7:28 PM
    Moderator
  • Do you mean how long am I letting the app run on the emulator before I click the Stop Debugging button, or how long do I leave the emulator open before closing the emulator?

    Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/

    Monday, December 15, 2014 7:59 PM
  • The point of my question is:  roaming does not take place immediately when you run the application. But let me step back a moment... how exactly are you expecting this information to show up on OneDrive?

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Monday, December 15, 2014 8:39 PM
    Moderator
  • I wasn't 100% sure how I expected it to show up, since this is my first time using ApplicationData.Current.RoamingFolder (my previous versions of this app were written for Windows Phone 7 using Silverlight and other ways of saving the file to OneDrive, so this is a complete rewrite for a Windows Runtime version). I looked through every directory on my entire OneDrive (since I don't have that much stuff there), but it wasn't in any of the directories. I realize that RoamingFolder synchronization does not take place immediately, which is part of why I wanted to make sure my code was correct (so that I didn't wait forever for something that would never happen). Approximately how long would I need to wait and is my code correctly written so that it will eventually synchronize? Thanks.

    Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/

    Monday, December 15, 2014 9:00 PM
  • Roaming folders do not roam to OneDrive at all.  Is there documentation that says otherwise?


    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Tuesday, December 16, 2014 12:57 PM
    Moderator
  • In that case, I guess I must have misread or misunderstood something somewhere. So I guess that brings up another question. What is the best way to debug RoamingFolder? Are there any good sites or blogs about how to debug RoamingFolder? Thanks.

    Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/

    Tuesday, December 16, 2014 4:23 PM