/// <summary>
        /// Read the contents of a isolated storage file as XML.
        /// </summary>
        /// <param name="fileName">File name of file to read from.</param>
        /// <returns>XML from the file.</returns>
        public XmlDocument ReadAsXml(IsolatedStorageFileName fileName)
        {
            var xmlDoc = new XmlDocument();

            xmlDoc.LoadXml(Read(fileName));
            return(xmlDoc);
        }
 /// <summary>
 /// Deletes a file from isolated storage.
 /// </summary>
 /// <param name="fileName">File name of file to delete.</param>
 public void Delete(IsolatedStorageFileName fileName)
 {
     using (var file = GetStorageFile())
     {
         file.DeleteFile(fileName.Name);
     }
 }
 /// <summary>
 /// Indicates whether the isolated storage file exists.
 /// </summary>
 /// <param name="fileName">File name.</param>
 /// <returns>True if the file exists; otherwise returns false.</returns>
 public bool Exists(IsolatedStorageFileName fileName)
 {
     using (var file = GetStorageFile())
     {
         return(file.FileExists(fileName.Name));
     }
 }
        public void SetUp()
        {
            _sut = new IsolatedStorageIo(IsolatedStorageFileType.UserStoreForApplication);

            _fileName = new IsolatedStorageFileName("IsolatedStorageIoTests", new Version(1, 0), ".txt");

            _sut.Delete(_fileName);
        }
        /// <summary>
        /// Read the contents of a isolated storage file.
        /// </summary>
        /// <param name="fileName">File name of file to read from.</param>
        /// <returns>Content from the file.</returns>
        public string Read(IsolatedStorageFileName fileName)
        {
            IsolatedStorageFile file = GetStorageFile();

            using (var stream = new IsolatedStorageFileStream(fileName.Name, FileMode.Open, file))
            {
                using (var reader = new StreamReader(stream))
                {
                    return(reader.ReadToEnd());
                }
            }
        }
        /// <summary>
        /// Writes string to a isolated storage file.
        /// </summary>
        /// <param name="fileName">File name of file to write to.</param>
        /// <param name="content">String to write to the file.</param>
        public void Write(IsolatedStorageFileName fileName, string content)
        {
            IsolatedStorageFile file = GetStorageFile();

            using (var stream = new IsolatedStorageFileStream(fileName.Name, FileMode.Create, file))
            {
                using (var writer = new StreamWriter(stream))
                {
                    writer.Write(content);
                }
            }
        }
 public ProgramSettingsFactory(IAppConfig appConfig, IsolatedStorageFileName settingsFileName)
 {
     _appConfig        = appConfig;
     _settingsFileName = settingsFileName;
 }
 /// <summary>
 /// Writes XML to a isolated storage file.
 /// </summary>
 /// <param name="fileName">File name of file to write to.</param>
 /// <param name="xmlDocument">XML document to write to isolated storage.</param>
 public void Write(IsolatedStorageFileName fileName, XmlDocument xmlDocument)
 {
     Write(fileName, xmlDocument.OuterXml);
 }