Example #1
0
 async void  init()
 {
     myFiles = await deserialize("demofiles.xml");
     myDemoFilesXML.Clear();
     foreach (demofilesXML.fileentry f in myFiles.fileentries)
     {
         myDemoFilesXML.Add(f);
         demofiles.Add(new DemoFile(f.filename, f.filedescription, f.filehelp));
     }
     
 }
Example #2
0
        async Task<demofilesXML> deserialize(string _filename)
        {
            //get folder
            StorageFolder PrintfilesFolder = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFolderAsync("printfiles");
            //get file
            StorageFile printfile = await PrintfilesFolder.GetFileAsync(_filename);
            if (printfile != null)
            {
                //read file
                Stream stream = await ReadFileContentsAsync(printfile);
                //read byte stream
                byte[] bXML = new byte[stream.Length];
                stream.Read(bXML, 0, (int)stream.Length);
                //convert to string
                string sXML = Encoding.UTF8.GetString(bXML, 0, bXML.Length);
                //deserialize string
                myFiles = demofilesXML.XmlDeserialize(sXML);

                return myFiles;
            }
            return new demofilesXML();
        }