How to add "Remember Me" Login Functionality?
Code:
<Grid x:Name="LayoutRoot" >
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<StackPanel Margin="70,50,70,50" Orientation="Vertical">
<TextBox Name="txtName"/>
<PasswordBox Name="txtPassword"/>
<Button Tap="Button_Tap"/>
</StackPanel>
<StackPanel Margin="70,430">
<CheckBox Name="cbStayIn" Content="StayIn"/>
</StackPanel>
</Grid>
When User checked in StayIn checkbox it should hold values of name and password.
Give Me Suggestion.
Responding your comment, it seems that the logic is a bit off. Your checkbox will be in it's default state regardless user checked it or not the last time he logged in. Try this way :
//on page load :
InitializeComponent();
//check if remember me checked the last time user login
bool stayin = false;
userSettings.TryGetValue<bool>("stayin", stayin);
//if checked, load username & password from iso store
if (stayin)
{
string Email = (string)userSettings["email"];
txtName.Text = Email;
string Password = (string)userSettings["password"];
txtPassword.Password = Password;
}
......
//on login button clicked
private void Button_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
//if remember me checked,
//save mail, password, and stayin = true in iso store
if (cbStayIn.IsChecked == true)
{
userSettings.Add("email", txtName.Text);
userSettings.Add("password", txtPassword.Password);
userSettings.Add("stayin", true);
}
}
Hope below code helps. dint compile the code, pardon the compilation Errors
If(checkbox.Selected == true)
{
//check if the UserName and PassWord are already stored
if (IsolatedStorageSettings.ApplicationSettings.Contains("userName"))
{
UserName.Text = IsolatedStorageSettings.ApplicationSettings["userName"].ToString();
}
else
{
IsolatedStorageSettings.ApplicationSettings["userName"] = UserNameTextBox.Text;
IsolatedStorageSettings.ApplicationSettings.Save();
}
if (IsolatedStorageSettings.ApplicationSettings.Contains("Password"))
{
PasswordBox.Text = IsolatedStorageSettings.ApplicationSettings["Password"].ToString();
}
else
{
IsolatedStorageSettings.ApplicationSettings["Password"] = PasswordBox.Text;
IsolatedStorageSettings.ApplicationSettings.Save();
}
}
using System.IO.IsolatedStorage;
namespace iso
{
public partial class LoginPage : PhoneApplicationPage
{
private IsolatedStorageSettings userSettings = IsolatedStorageSettings.ApplicationSettings;
public LoginPage()
{
InitializeComponent();
bool stayin = false;
// userSettings.TryGetValue<bool>("stayin", stayin);
userSettings.TryGetValue<bool>("stayin", out stayin);
if (stayin)
{
string Email = (string)userSettings["email"];
txtName.Text = Email;
string Password = (string)userSettings["password"];
txtPassword.Password = Password;
}
}
private void Button_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
if (cbStayIn.IsChecked == true)
{
userSettings.Add("email", txtName.Text);// Error :An exception of type 'System.ArgumentException' occurred in mscorlib.ni.dll but was not handled in user code
userSettings.Add("password", txtPassword.Password);
userSettings.Add("stayin", true);
}
}
}
}
public LoginPage()
{
InitializeComponent();
if (cbStayIn.IsChecked == true)
{
if (userSettings.Contains("Name"))
{
txtName.Text = userSettings["Name"].ToString();
}
if (userSettings.Contains("Password"))
{
txtPassword.Password = userSettings["Password"].ToString();
}
}
}
private void Button_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
//
try
{
if ((userSettings.Contains("UserName")) == false)
{
userSettings.Add("Name", txtName.Text);
}
if ((userSettings.Contains("Pass")) == false)
{
userSettings.Add("Password", txtPassword.Password);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}
Related
Please send me in the right direction here - I'm really confused.
See, I have this App.Shell:
<?xml version="1.0" encoding="UTF-8" ?>
<Shell
x:Class="ExpensesMobile.AppShell"
x:DataType="Login_VM:Login_VM"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:Approvals="clr-namespace:ExpensesMobile.View.Approvals"
xmlns:Settings="clr-namespace:ExpensesMobile.View.AppSettings"
xmlns:Login_VM="clr-namespace:ExpensesMobile.ViewModel.Login"
xmlns:Login="clr-namespace:ExpensesMobile.View.Login"
xmlns:Globals="clr-namespace:ExpensesMobile"
xmlns:ExpenseReports="clr-namespace:ExpensesMobile.View.ExpenseReports"
xmlns:res="clr-namespace:ExpensesMobile.Resources.Strings"
Title="{x:Static res:AppRes.ExpenseReports}"
Shell.FlyoutBehavior="Disabled">
<Shell.Items>
<ShellContent x:Name="Login" ContentTemplate="{DataTemplate Login:Login}" Route="Login" Shell.FlyoutBehavior="Disabled" Shell.NavBarIsVisible="False" ></ShellContent>
</Shell.Items>
<TabBar Route="Login">
<ShellContent ContentTemplate="{DataTemplate Login:Login}" Shell.FlyoutBehavior="Disabled" Shell.NavBarIsVisible="False" ></ShellContent>
</TabBar>
<TabBar x:Name="MyTabBar" Shell.NavBarHasShadow="true" Route="Home">
<Tab
x:Name="tabExpenseReports"
Title="{x:Static res:AppRes.ExpenseReports}"
Icon="ExpenseReports"
Shell.BackgroundColor="#001933"
Shell.ForegroundColor="#AB1300">
<ShellContent
x:Name="Pending"
ContentTemplate="{DataTemplate ExpenseReports:Pending}"
Route="Pending"
Title="{x:Static res:AppRes.Pending}"
Icon="pending.svg"
Shell.NavBarIsVisible="False">
</ShellContent>
<ShellContent
x:Name="Finalized"
ContentTemplate="{DataTemplate ExpenseReports:Finalized}"
Route="Finalized"
Title="{x:Static res:AppRes.Finalized}"
Icon="finalized.svg"
Shell.NavBarIsVisible="False">
</ShellContent>
</Tab>
<Tab
x:Name="tabApprovals"
Title="{x:Static res:AppRes.Approvals}"
Icon="approvals"
IsEnabled="{Binding TabApprovalsIsEnabled}"
Shell.BackgroundColor="#AB1300"
Shell.ForegroundColor="#001933">
<ShellContent
x:Name="Approvals"
ContentTemplate="{DataTemplate Approvals:Approvals}"
Shell.NavBarIsVisible="False"
Route="Approvals"
Title="{x:Static res:AppRes.Approvals}"
Icon="approvals.svg">
</ShellContent>
<ShellContent
x:Name="Approved"
ContentTemplate="{DataTemplate ExpenseReports:Approved}"
Shell.NavBarIsVisible="False"
Route="Approved"
Title="{x:Static res:AppRes.Approved}"
Icon="approved.svg">
</ShellContent>
</Tab>
<Tab
Title="{x:Static res:AppRes.Settings}"
Icon="settings" Shell.BackgroundColor="#193300"
x:Name="tabSettings">
<ShellContent
ContentTemplate="{DataTemplate Settings:Settings}"
Route="Settings" />
</Tab>
</TabBar>
</Shell>
In the Login page I decide whether the logged-in user is an admin or not. If he isn't, then he shouldn't have access to the tab "Approvals".
I have tried in several ways to make the tab disabled in this case. This is what I have right now:
In the class "Globals" I have this (I have them in the Globals class because I will need to refer to these values across the application):
using ExpensesMobile.Model;
namespace ExpensesMobile
{
public static class Globals
{
public static ExpensesMobileDB ExpensesMobileDB;
public static LoginStatus loginStatus;
public enum LoginStatus
{
loginRefused,
loginAcceptedAdmin,
loginAcceptedRegularUser
}
}
}
In Login_VM I have this code:
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using ExpensesMobile.Resources.Strings;
using ExpensesMobile.Services;
using ExpensesMobile.Utils;
using ExpensesMobile.View.ExpenseReports;
using System.Diagnostics;
using static ExpensesMobile.Globals;
namespace ExpensesMobile.ViewModel.Login
{
[QueryProperty(nameof(Login), "Login")]
public partial class Login_VM : Base_VM
{
public readonly LoginService loginService;
private readonly IConnectivity connectivity;
[ObservableProperty]
private string password;
[ObservableProperty]
private bool tabApprovalsIsEnabled = false;
[ObservableProperty]
private string username;
public Login_VM(LoginService loginService, IConnectivity connectivity)
{
this.loginService = loginService;
this.connectivity = connectivity;
//TEMP CODE - DEBUG
username = ".....";
password = ".....";
}
private static async Task ShowToast(LoginStatus loginStatus)
{
string text;
if (loginStatus == LoginStatus.loginAcceptedAdmin)
text = AppRes.LoginConfirmationManager;
else
text = AppRes.LoginConfirmationUser;
await Utils.Utils.ShowToast(text);
}
[RelayCommand]
private async Task LoginAsync()
{
if (IsBusy)
{
return;
}
try
{
if (connectivity.NetworkAccess != NetworkAccess.Internet)
{
await Shell.Current.DisplayAlert(AppRes.MsgConnectivity1, AppRes.MsgConnectivity2, "OK"); //No connectivity, Please check your internet connection and then try again;
return;
}
IsBusy = true;
LoginStatus loginStatus = LoginService.Login(username, password);
if (loginStatus == LoginStatus.loginAcceptedAdmin)
{
TabApprovalsIsEnabled = true;
await ShowToast(loginStatus);
await Shell.Current.GoToAsync($"//{nameof(Pending)}");
}
else if (LoginService.Login(username, password) == LoginStatus.loginAcceptedRegularUser)
{
TabApprovalsIsEnabled = false;
await ShowToast(loginStatus);
await Shell.Current.GoToAsync($"//{nameof(Pending)}");
}
else if (LoginService.Login(username, password) == LoginStatus.loginRefused)
{
await Shell.Current.DisplayAlert(AppRes.Login, AppRes.LoginWrongUsernameOrPass, "OK"); //Wrong username and/or password !
}
Globals.loginStatus = loginStatus;
}
catch (Exception ex)
{
Debug.WriteLine($"Unable to login: {ex.Message}");
ErrorHandling.HandleError(ex);
}
finally
{
IsBusy = false;
}
}
}
}
If I login as a regular user, the line 'tabApprovalsIsEnabled = false;' executes.
I have added this line because I wanted App.Shell to bind to Login_VM and not to Globals directly (that is a regular class, and has no knowledge of ObservableProperties).
However, although the tab Approvals has the xaml 'IsEnabled="{Binding TabApprovalsIsEnabled}"', this is not taken into consideration and my tab remains enabled.
Obviously I am missing something, and probably I am ignorant enough of the sequence of operations in MAUI - probably the code above executes and sets the property "tabApprovalsIsEnabled" to false AFTER the binding in AppShell has been done, I don't know....
How could I solve this problem, please ?
Thank you very much,
Alex.
You should reset the value of property TabApprovalsIsEnabled not tabApprovalsIsEnabled .
Please refer to the following code:
[RelayCommand]
private async Task LoginAsync()
{
// other code
try
{
// other code
LoginStatus loginStatus = LoginService.Login(username, password);
if (loginStatus == LoginStatus.loginAcceptedAdmin)
{
// replace `tabApprovalsIsEnabled` with `TabApprovalsIsEnabled`
//tabApprovalsIsEnabled = true;
TabApprovalsIsEnabled = true;
//........
}
else if (LoginService.Login(username, password) == LoginStatus.loginAcceptedRegularUser)
{
// replace `tabApprovalsIsEnabled` with `TabApprovalsIsEnabled`
// tabApprovalsIsEnabled = false;
TabApprovalsIsEnabled = true;
}
else if (LoginService.Login(username, password) == LoginStatus.loginRefused)
{
//Wrong username and/or password !
await Shell.Current.DisplayAlert(AppRes.Login, AppRes.LoginWrongUsernameOrPass, "OK");
}
Globals.loginStatus = loginStatus;
}
catch (Exception ex)
{
Debug.WriteLine($"Unable to login: {ex.Message}");
ErrorHandling.HandleError(ex);
}
finally
{
IsBusy = false;
}
}
Note:
We need set BindingContext for AppShell.xaml.cs. Then if we change the value of property TabApprovalsIsEnabled of the current ViewModel, the UI could refresh automatically.
public partial class AppShell : Shell
{
Login_VM _VM;
public AppShell()
{
InitializeComponent();
Routing.RegisterRoute("DetailPage", typeof(DetailPage));
_VM = new Login_VM();
this.BindingContext = _VM;
}
[Obsolete]
protected override void OnAppearing()
{
base.OnAppearing();
Device.StartTimer(TimeSpan.FromSeconds(5), () =>
{
_VM.TabApprovalsIsEnabled = false;
return false;
});
}
}
I add a toggle button on Windows Phone 8 . When i checked (on), its save a value in Isolated storage and I check that value in constructor whatever it has a toggle value or null. If there is a toggle value I want to display toggle button checked . But I dont know the property to how to checked it when application is run .
Toggle Button XAML :
<toolkit:ToggleSwitch x:Name="toggle" Content="On" Width="165" FontSize="28" VerticalAlignment="Center" HorizontalAlignment="Right"/>
C# :
public Subscription()
{
InitializeComponent();
this.toggle.Checked += new EventHandler<RoutedEventArgs>(toggle_Checked);
this.toggle.Unchecked += new EventHandler<RoutedEventArgs>(toggle_Unchecked);
var appSettings = IsolatedStorageSettings.ApplicationSettings;
if (HasSValue() == "NoValue")
{
// Here i want to Display toggle button unchecked
}
else
{
// Here i want to Display toggle button checked
}
}
void toggle_Unchecked(object sender, RoutedEventArgs e)
{
this.toggle.Content = "Off";
this.toggle.SwitchForeground = new SolidColorBrush(Colors.Red);
var appSettings = IsolatedStorageSettings.ApplicationSettings;
appSettings.Remove("toggleValue");
appSettings.Save();
}
void toggle_Checked(object sender, RoutedEventArgs e)
{
this.toggle.Content = "On";
this.toggle.SwitchForeground = new SolidColorBrush(Colors.Green);
MessageBox.Show("R U Sure ?");
var appSettings = IsolatedStorageSettings.ApplicationSettings;
appSettings.Add("toggleValue", "MAHIN");
appSettings.Save();
}
public string HasSValue()
{
var appSettings = IsolatedStorageSettings.ApplicationSettings;
if (appSettings.Contains("toggleValue"))
{
return (string) appSettings["toggleValue"];
}
else
{
return "NoValue";
}
}
Try this
if (HasSValue() == "NoValue")
{
this.toggle.IsChecked = false;
}
else
{
this.toggle.IsChecked = true;
}
Hope this helps
Update your Constructor as follows
public Subscription()
{
InitializeComponent();
var appSettings = IsolatedStorageSettings.ApplicationSettings;
if (HasSValue() == "NoValue")
{
// Here i want to Display toggle button unchecked
}
else
{
// Here i want to Display toggle button checked
}
this.toggle.Checked += new EventHandler<RoutedEventArgs>(toggle_Checked);
this.toggle.Unchecked += new EventHandler<RoutedEventArgs>(toggle_Unchecked);
}
how can i reset or delete old data in Telerik RadDataBoundListBox
Json parse and display in RadDataBoundListBox
RadDataBoundListBox load old data every time, if i click button to load new data i want to delete or reset old data becouse every time displaying old data
public void getMainData()
{
string mainUrlData = "http://www.mydomain.com/app.json";
WebClient wc = new WebClient();
wc.DownloadStringCompleted += wc_DownloadStringCompleted;
wc.DownloadStringAsync(new Uri(mainUrlData));
}
void wc_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
try
{
string result = e.Result.ToString();
JsonConvert.PopulateObject(result, PopulateData);
NewsList.ItemsSource = PopulateData;
}
}
Little late, hope this helps..
With MVVMLight
Use HttpClient:
public async Task<ObservableCollection<T>> GetAll()
{
var client = new HttpClient();
client.DefaultRequestHeaders.Accept.Add(MediaTypeWithQualityHeaderValue.Parse(jsonMediaType));
//if (useToken)
//client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Token);
var json = await client.GetStringAsync(String.Format("{0}{1}{2}", apiUrl, addressSuffix, apiKey)).ConfigureAwait(false);
Debug.WriteLine(json);
JObject o = JObject.Parse(json);
Debug.WriteLine(o);
return await Task.Factory.StartNew(() => JsonConvert.DeserializeObject<ObservableCollection<T>>(o[moduleName].ToString()));
}
ItemSource:
private ObservableCollection<Ticket> _myTickets;
public ObservableCollection<Ticket> MyTickets
{
get
{
return _myTickets;
}
set
{
_myTickets = value;
RaisePropertyChanged(() => MyTickets);
}
}
Telerik RadBoundListBox:
<telerikPrimitives:RadDataBoundListBox
x:Name="radDataBoundListBox"
ItemsSource="{Binding TicketList}"
ItemTemplate="{StaticResource ListBoxItemTemplate}"
ItemContainerStyle="{StaticResource ItemContainerStyle}"
SelectedItem="{Binding SelectedTicket, Mode=TwoWay}"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Height="750"
ScrollViewer.VerticalScrollBarVisibility="Auto"
UseOptimizedManipulationRouting="False"
EmptyContent="Laden..."
IsPullToRefreshEnabled="True">
<i:Interaction.Triggers>
<i:EventTrigger EventName="RefreshRequested">
<cmd:EventToCommand
Command="{Binding RefreshRequested}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</telerikPrimitives:RadDataBoundListBox>
Refresh Command:
private RelayCommand _refreshCommand;
public RelayCommand RefreshRequested
{
get
{
return _refreshCommand
?? (_refreshCommand = new RelayCommand(
() =>
{
ExecuteRefreshCommand();
}));
}
}
public async void ExecuteRefreshCommand()
{
var tickets = await _dataService.GetAll();
if (tickets != null)
{
_ticketList.Clear();
foreach (var ticket in tickets)
{
_ticketList.Add(ticket);
Debug.WriteLine(ticket.name);
}
Messenger.Default.Send(new HandleViewMessage() { StopPullToRefresh = true });
RaisePropertyChanged(() => TicketList);
}
}
I have a problem that I can't really figure out, and I am really desperate now - I've no idea why it's happening:(
So here is the problem: I am writing a kind of Guess that Tune app. The first page is a menu page, that a user can press "Play" button, and he will navigate to a GenreSelectPage where he selects a genre and navigates to a GamePage. I wanted to handle BackButtonPress on GamePage - when a user hits BackButton, he navigates to MainPage, not GenreSelectPage. Here is the code:
private void PhoneApplicationPage_BackKeyPress(object sender, CancelEventArgs e)
{
base.OnBackKeyPress(e);
this.player.Pause();
var result = MessageBox.Show(AppResources.GamePageAlert, "Warning", MessageBoxButton.OKCancel);
if (result == MessageBoxResult.OK)
{
//NavigationService.RemoveBackEntry();
//App.RootFrame.Navigate(new Uri(#"/MainPage.xaml", UriKind.Relative));
}
else
{
this.player.Play();
e.Cancel = true;
}
}
However, I encoountered a big problem here I can't really solve. When I move back to MainMEnu, than go again to GenreSelectPage and choose the same genre, everything is ok - the app navigates to GamePage where there is list of 4 answers. However, if I choose another genre, the listBox at GamePage is populated with 12 or 15 items. On the other hand, when I comment navigation to MainPage and normally go back, everything works alright.
Here is my GenrePage Code:
public GenresPage()
{
InitializeComponent();
this.DataContext = App.ViewModel.GenreHelper;
}
private async void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
{
this.genresListBox.SelectedIndex = -1;
this.progressBar.Visibility = System.Windows.Visibility.Visible;
this.genresListBox.ItemsSource = await App.ViewModel.GenreHelper.GetGenres();
this.progressBar.Visibility = System.Windows.Visibility.Collapsed;
ClearCollections();
}
private static void ClearCollections()
{
if (App.ViewModel.TracksCollection.Count != 0)
{
App.ViewModel.TracksCollection.Clear();
App.ViewModel.TrackCounter = 0;
}
if (App.ViewModel.AnswerCollection.Count > 0)
{
App.ViewModel.AnswerCollection.Clear();
}
}
private async void NavigateToPlay(object sender, RoutedEventArgs e)
{
if (this.genresListBox.SelectedIndex != -1)
{
this.progressBar.Visibility = System.Windows.Visibility.Visible;
await App.ViewModel.GetSongs();
await App.ViewModel.GetAnswers();
this.progressBar.Visibility = System.Windows.Visibility.Collapsed;
NavigationService.Navigate(new Uri(#"/Views/GamePage.xaml", UriKind.Relative));
}
}
UPDATE
On my GamePage I am only assigning DataContext and duration to MediaElement:
public partial class GamePage : PhoneApplicationPage
{
public GamePage()
{
InitializeComponent();
this.DataContext = App.ViewModel;
}
private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
{
var trackId = App.ViewModel.TracksCollection[App.ViewModel.TrackCounter].Id;
var sampleUri = App.ViewModel.GetSampleUri(trackId);
player.Source = new Uri(sampleUri.AbsoluteUri);
player.Play();
}
private void GetTrackDuration(object sender, RoutedEventArgs e)
{
var player = (MediaElement)sender;
if (player.CurrentState == System.Windows.Media.MediaElementState.Playing)
{
playerSeekBar.Maximum = player.NaturalDuration.TimeSpan.TotalSeconds;
}
}
private void PhoneApplicationPage_BackKeyPress(object sender, CancelEventArgs e)
{
base.OnBackKeyPress(e);
this.player.Pause();
var result = MessageBox.Show(AppResources.GamePageAlert, "Warning", MessageBoxButton.OKCancel);
if (result == MessageBoxResult.OK)
{
//NavigationService.RemoveBackEntry();
//App.RootFrame.Navigate(new Uri(#"/MainPage.xaml", UriKind.Relative));
}
else
{
this.player.Play();
e.Cancel = true;
}
}
}
If anyone can point out what I am doing wrong, I would be really greatful - I am fighting it all day and I have no idea what's causing it.
Thank You very much in advance!!
This is the function I used to get the string content from the website ..the problem is when executed first I cannot get the string content (App.Data2 = userprofile.InnerText;) since it skips to the next line (App.savecontent(App.Data2);) so that I get an empty string. If I recall the function I could get the string. Is there any possibility to solve this issue I need the string value first time automatically
This is my Page.cs code :
namespace Project_Future1
{
public partial class Page1 : PhoneApplicationPage
{
public Page1()
{
InitializeComponent();
{
string url = "http://www.astrosage.com/horoscope/daily-";
HtmlWeb.LoadAsync(url + App.Data + "-horoscope.asp", DownLoad);
}
data();
App.loadContent();
change2();
}
public void change2()
{
try
{
Util.LiveTile.UpdateLiveTile(App.Data2);
}
catch (Exception)
{
}
}
public void DownLoad(object sender, HtmlDocumentLoadCompleted e)
{
if (e.Error == null)
{
HtmlDocument doc = e.Document;
if (doc != null)
{
var userprofile = doc.DocumentNode.SelectSingleNode("//div[#class = 'ui-large-content']");
App.Data2 = userprofile.InnerText;
App.savecontent(App.Data2);
}
}
}
private void data()
{
SelectedSign.Text = App.Data;
SSContent.Text = App.Data2;
}
private void Refresh_click(object sender, EventArgs e)
{
SSContent.Text = App.Data2;
}
private void Fb_Click(object sender, EventArgs e)
{
NavigationService.Navigate(new Uri("/FB.xaml", UriKind.Relative));
}
}
}
this is my App.Xaml.cs File :
public static void savecontent(string save)
{
try
{
if (!string.IsNullOrEmpty(appFileName1))
{
IsolatedStorageFile oIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication();
oIsolatedStorage.CreateDirectory(appFolder1);
StreamWriter writeFile = new StreamWriter(new IsolatedStorageFileStream(appFolder1 + "\\" + appFileName1, FileMode.OpenOrCreate, oIsolatedStorage));
writeFile.WriteLine(save);
writeFile.Close();
}
}
catch (Exception)
{
throw;
}
}
this is my code to load the content from the storage :
public static void loadContent()
{
IsolatedStorageFile oIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication();
if (oIsolatedStorage.DirectoryExists(appFolder1))
{
IsolatedStorageFileStream fileStream = oIsolatedStorage.OpenFile(appFolder1 + "\\" + appFileName1, FileMode.Open, FileAccess.Read);
using (StreamReader reader = new StreamReader(fileStream))
{
App.Data2 = reader.ReadLine();
reader.Close();
}
}
}