using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.IO.IsolatedStorage;
using System.IO;
namespace GTA_V_Guide._100Check
{
public partial class Hobbies : PhoneApplicationPage
{
Boolean IsChecked;
IsolatedStorageFile gtavStorage = IsolatedStorageFile.GetUserStoreForApplication();
StreamReader readFile = null;
string hobbies;
public Hobbies()
{
InitializeComponent();
validate();
checkandreadFile();
}
public void validate()
{
using (StreamWriter writeFile = new StreamWriter(new IsolatedStorageFileStream("Hobbies.txt", FileMode.Create, FileAccess.Write, gtavStorage)))
{
//StringWriter str = new StringWriter();
//hobbies = "Handgun";
//write
string Handgun = "Handgun, False";
if (chkHandgun.IsChecked == true)
{
StringWriter str = new StringWriter();
Handgun = "Handgun, True";
writeFile.WriteLine(Handgun, true);
writeFile.WriteLine(str.ToString());
writeFile.Close();
}
}
}//end val
public void checkandreadFile()
{
using (StreamReader reader = readFile)
readFile = new StreamReader(new IsolatedStorageFileStream("Hobbies.txt", FileMode.Open, gtavStorage));
hobbies = readFile.ReadToEnd();//decalired hobbies at the top
if (hobbies.Contains("Handgun, True"))
{
chkHandgun.IsChecked = true;
}
else
{
chkHandgun.IsChecked = false;
}
readFile.Close();
//IsolatedStorageFileStream fileStream = gtavStorage.OpenFile("Hobbies.txt", FileMode.Open, FileAccess.Read);
//using (StreamReader reader = new StreamReader(fileStream))
//{ //Visualize the text data in a TextBlock text
// this.hobbies = reader.ReadToEnd();
// if (hobbies.Contains("Handgun, True"))
// {
// chkHandgun.IsChecked = true;
// }
//}
}//End readFile
}
}