public void GetData() { using (var read = IsolatedStorageFile.GetUserStoreForApplication()) { if (read.FileExists(filename)) { try { using (StreamReader sw = new StreamReader(new IsolatedStorageFileStream(filename, FileMode.Open, read))) { string rea = sw.ReadToEnd(); EasyPin.XML x= new EasyPin.XML(); list = x.Retrive(rea); Dispatcher.BeginInvoke(() => listBox1.ItemsSource = list); key = true; } } catch (IsolatedStorageException ex) { Dispatcher.BeginInvoke(() => MessageBox.Show("Error")); } } else { Dispatcher.BeginInvoke(() => MessageBox.Show("Does not exist")); } } }
// STEP4 STEP4 STEP4 private void ReadWebRequestCallbackR(IAsyncResult callbackResult) { try { HttpWebRequest myRequest = (HttpWebRequest)callbackResult.AsyncState; HttpWebResponse myResponse = (HttpWebResponse)myRequest.EndGetResponse(callbackResult); using (StreamReader httpwebStreamReader = new StreamReader(myResponse.GetResponseStream())) { string fil = httpwebStreamReader.ReadToEnd(); FileToSave = fil; EasyPin.XML x = new EasyPin.XML(); list = x.Retrive(fil); Dispatcher.BeginInvoke(() => Loading_for_Read.Visibility = Visibility.Collapsed); Dispatcher.BeginInvoke(() => listBox1.Visibility = Visibility.Visible); Dispatcher.BeginInvoke(() => listBox1.ItemsSource = list); } myResponse.Close(); } catch (Exception d) { Dispatcher.BeginInvoke(() => Loading_for_Read.Visibility = Visibility.Collapsed); Dispatcher.BeginInvoke(() => txt_SearchR.Text="Page Not Found"); } }
private void ReadWebRequestCallback(IAsyncResult callbackResult) { try { HttpWebRequest myRequest = (HttpWebRequest)callbackResult.AsyncState; HttpWebResponse myResponse = (HttpWebResponse)myRequest.EndGetResponse(callbackResult); using (StreamReader httpwebStreamReader = new StreamReader(myResponse.GetResponseStream())) { string fil = httpwebStreamReader.ReadToEnd(); string FileToSave = fil; EasyPin.XML x = new EasyPin.XML(); list = x.Retrive(fil); FileManip manip = new FileManip(); if (manip.Update(filename, FileToSave) == "Updated") { Dispatcher.BeginInvoke(() => image1.Visibility = Visibility.Collapsed); Dispatcher.BeginInvoke(() => listBox1.ItemsSource = list); Dispatcher.BeginInvoke(() => listBox1.Visibility = Visibility.Visible); } } myResponse.Close(); } catch (Exception s) { Dispatcher.BeginInvoke(() => image1.Visibility = Visibility.Collapsed); Dispatcher.BeginInvoke(() => listBox1.Visibility = Visibility.Visible); } }