public async void Confirm() { if (string.IsNullOrEmpty(Name)) { OnConfirmEventHandler?.Invoke(this, ConfirmEnum.AccountNotExist); return; } //用户存在 var folder = await ApplicationData.Current.LocalFolder.CreateFolderAsync("data", CreationCollisionOption.OpenIfExists); try { folder = await folder.GetFolderAsync(Name); } catch (DirectoryNotFoundException) { OnConfirmEventHandler?.Invoke(this, ConfirmEnum.AccountNotExist); return; } catch (FileNotFoundException) { OnConfirmEventHandler?.Invoke(this, ConfirmEnum.AccountNotExist); return; } try { var file = await folder.GetFileAsync("account"); //用户账户是否一样,一般都是一样 string str; using (StreamReader stream = new StreamReader(await file.OpenStreamForReadAsync())) { str = stream.ReadLine(); if (Name != str) { //不会 } str = stream.ReadLine(); } if (Md5(Key) != str) { OnConfirmEventHandler?.Invoke(this, ConfirmEnum.KeyError); return; } AreAccountConfirm = true; Folder = new VirtualFolder() { Name = Name, Path = "~", FolderStorage = folder }; await Read(); OnConfirmEventHandler?.Invoke(this, ConfirmEnum.Success); } catch (FileNotFoundException) { throw new FileNotFoundException("验证错误,系统错误,没有用户文件"); } }