我有IsolatedStorage
文件。如果文件存在,我想重定向到登录页面或创建帐户页面。的Windows Phone 8 - 导航错误
如果犯规存在的文件,应用程序进入到页面,将密码创建并保存,和应用程序重定向到登录页面。但是,如果IsolatedStorage中的文件存在,它不会直接。
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!");
}
}
实际的消息做节目,所以它被称为如果一个文件不存在,则执行别的,所以我的逻辑是合理的。
的FileExists()
功能这里所说的。
public MainPage()
{
InitializeComponent();
fileExists();
}
其他重定向发生在这里
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));
}
错误是System.NullReferenceException
但在用户代码中没有处理。
真正offtopic在这里,请散列或加密你的密码文件,具有一些奇特的编码和改装WP8很容易访问isolatedStorage – EaterOfCode 2013-03-22 10:41:35
我会的,这是真的只是开始!我刚开始的C#和WP昨天和加密的项目,而不是东西,我会看几个星期的很大一部分。虽然谢谢! – 2013-03-22 10:44:57