I have a file in IsolatedStorage
. If the file exists, I want to redirect to the login page or Create Account page.
If the file doesnt exist, the app goes to the Create page, a password is created and saved, and the app redirects to the Login page. However, if the file in IsolatedStorage exists, it won't direct.
private void fileExists()
{
IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication();
if (store.FileExists("passwordFile"))
{
//NavigationService.Navigate(new Uri("/Login.xaml", UriKind.Relative));
MessageBox.Show("Should be redirecting here");
}
else
{
MessageBox.Show("Welcome. Please create an account. Ensure that you remember your password!");
}
}
The actual message does show so it's being called and if a file does not exist, the else is executed so my logic is sound.
The FileExists()
function is called here.
public MainPage()
{
InitializeComponent();
fileExists();
}
The other redirect happens here
if ((password1.Password == password2.Password) & (password1.Password.Trim().Length > 0 || password2.Password.Trim().Length > 0))
{
byte[] PasswordByte = Encoding.UTF8.GetBytes(password1.Password);
byte[] ProtectedPassword = ProtectedData.Protect(PasswordByte, null);
this.WritePasswordToFile(ProtectedPassword);
NavigationService.Navigate(new Uri("/Login.xaml", UriKind.Relative));
}
The error is a System.NullReferenceException
but was not handled in user code.