Exemplo n.º 1
0
        /// <summary>
        /// Saves data to a file.
        /// </summary>
        /// <param name="fileName">Name of the file to write to</param>
        /// <param name="data">The data to save</param>
        public async Task SaveToFileAsync(string fileName, T data)
        {
            var file = await cacheFolder.CreateFileAsync(fileName);

            using (var stream = await file.OpenStreamForWriteAsync())
            {
                XmlSerializer mySerializer = new XmlSerializer(typeof(T));
                mySerializer.Serialize(stream, data);
            }
        }
Exemplo n.º 2
0
        public static async Task OpenLog(CacheFolder cache)
        {
            if (log == null)
            {
                try
                {
                    var file = await cache.CreateFileAsync("log.txt");

                    log = new StreamWriter(await file.OpenStreamForWriteAsync());
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("Error opening log: " + ex.Message);
                }
            }
        }