当前位置: 首页>>代码示例>>C#>>正文


C# IsolatedStorageFileStream.Dispose方法代码示例

本文整理汇总了C#中System.IO.IsolatedStorage.IsolatedStorageFileStream.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# IsolatedStorageFileStream.Dispose方法的具体用法?C# IsolatedStorageFileStream.Dispose怎么用?C# IsolatedStorageFileStream.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.IsolatedStorage.IsolatedStorageFileStream的用法示例。


在下文中一共展示了IsolatedStorageFileStream.Dispose方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MenuItem_Click

        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {

            MenuItem menu = sender as MenuItem;
            string strTemp = menu.Tag.ToString();

            using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
            {
                try
                {
                    IsolatedStorageFileStream location;

                    location = new IsolatedStorageFileStream("favoriteRoutes.dat", System.IO.FileMode.Open, storage);
                    StreamReader sr = new StreamReader(location);
                    string content = sr.ReadToEnd();
                    sr.Close();
                    location.Dispose();
                    content = content.Replace(strTemp, "");

                    location = new IsolatedStorageFileStream("favoriteRoutes.dat", System.IO.FileMode.Truncate, storage);
                    StreamWriter sw = new StreamWriter(location);
                    sw.Write(content);
                    sw.Close();
                    location.Dispose();
                    
                }
                catch (Exception e1)
                {
                    Debug.WriteLine(e1.Message);
                }
            }

            llsFavRoutes.ItemsSource = null;
            BindData();
        }
开发者ID:zongjingyao,项目名称:WP8-OnlineBus,代码行数:35,代码来源:FavoritePage.xaml.cs

示例2: LoadClues

        // this code is modfied code from the following tutorial
        // http://blogs.msdn.com/b/mingfeis_code_block/archive/2010/10/03/windows-phone-7-how-to-store-data-and-pass-data-between-pages.aspx
        public void LoadClues()
        {
            EnterClues();
            string elementNumber;

            using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
            {
                for (int i=0; i < noClues; i++)
                {
                    elementNumber = "number"+clueId[i].ToString();
                    XDocument _doc = new XDocument();
                    XElement _clue = new XElement(elementNumber);
                    XAttribute _clueId = new XAttribute("clueId", clueId[i]);
                    XAttribute _clueText = new XAttribute("clueText", clueText[i]);
                    XAttribute _barcodeRef = new XAttribute("barcodeRef", barcodeRef[i]);
                    XAttribute _location = new XAttribute("location", location[i]);
                    XAttribute _locInfo = new XAttribute("locInfo", locInfo[i]);
                    XAttribute _latitude = new XAttribute("latitude", latitude[i]);
                    XAttribute _longitude = new XAttribute("longitude", longitude[i]);

                    _clue.Add(_clueId, _clueText, _barcodeRef, _location, _locInfo, _latitude, _longitude);

                    _doc = new XDocument(new XDeclaration("1.0", "utf-8", "yes"), _clue);
                    IsolatedStorageFileStream memory = new IsolatedStorageFileStream(elementNumber + ".clue", System.IO.FileMode.Create, storage);

                    System.IO.StreamWriter file = new System.IO.StreamWriter(memory);
                    _doc.Save(file);

                    file.Dispose();
                    memory.Dispose();
                }

            }
        }
开发者ID:borgidiom,项目名称:UC-Scanager-Hunt,代码行数:36,代码来源:Clues.cs

示例3: BindData

        private void BindData()
        {
            using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
            {
                try
                {
                    ObservableCollection<Route> routes = new ObservableCollection<Route>();
                    IsolatedStorageFileStream location = new IsolatedStorageFileStream("favoriteRoutes.dat", System.IO.FileMode.Open, storage);
                    StreamReader sr = new StreamReader(location);
                    string content = sr.ReadToEnd();
                    string[] strRoutes = content.Split(';');
                    foreach(string strTempRoute in strRoutes)
                    {
                        Route route = new Route();
                        string[] strRoute = strTempRoute.Split(',');
                        if(strRoute[0] == WebService.GetCity())
                        {
                            route.StartStat = strRoute[1];
                            route.EndStat = strRoute[2];
                            route.Info = strTempRoute + ";";
                            routes.Add(route);
                        }
                    }
                    llsFavRoutes.ItemsSource = routes;
                    location.Dispose();
                }
                catch (Exception e1)
                {
                    Debug.WriteLine(e1.Message);
                }

            }
        }
开发者ID:zongjingyao,项目名称:WP8-OnlineBus,代码行数:33,代码来源:FavoritePage.xaml.cs

示例4: PhoneApplicationPage_Loaded

        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {
            IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication();

            if (!storage.FileExists("LeaveSettings.xml"))
            {
                this.PayPeriodBase.Text = PayPeriodUtilities.GetCurrentPayPeriod().AddDays(-1).ToShortDateString();
                this.AnnualBalance.Focus();
            }
            else
            {
                using (storage)
                {
                    XElement _xml;
                    IsolatedStorageFileStream location = new IsolatedStorageFileStream(@"LeaveSettings.xml", System.IO.FileMode.Open, storage);
                    System.IO.StreamReader file = new System.IO.StreamReader(location);
                    _xml = XElement.Parse(file.ReadToEnd());
                    if (_xml.Name.LocalName != null)
                    {
                        this.AnnualBalance.Text = _xml.Attribute("AnnualBalance").Value;
                        this.SickBalance.Text = _xml.Attribute("SickBalance").Value;
                        this.AnnualAccrue.Text = _xml.Attribute("AnnualAccrue").Value;
                        this.SickAccrue.Text = _xml.Attribute("SickAccrue").Value;
                        this.PayPeriodBase.Text = _xml.Attribute("PayPeriod").Value;
                    }
                    file.Dispose();
                    location.Dispose();
                }
            }
        }
开发者ID:DragonRiderIL,项目名称:LeaveBalancerRepo,代码行数:30,代码来源:SettingsPage.xaml.cs

示例5: CopyFromContentToStorage

 private void CopyFromContentToStorage(IsolatedStorageFile ISF, String SourceFile, String DestinationFile)
 {
     Stream Stream = Application.GetResourceStream(new Uri(SourceFile, UriKind.Relative)).Stream;
     IsolatedStorageFileStream ISFS = new IsolatedStorageFileStream(DestinationFile, System.IO.FileMode.Create, System.IO.FileAccess.Write, ISF);
     CopyStream(Stream, ISFS);
     ISFS.Flush();
     ISFS.Close();
     Stream.Close();
     ISFS.Dispose();
 }
开发者ID:hoangchunghien,项目名称:ChineseChessLearning,代码行数:10,代码来源:App.xaml.cs

示例6: Questions

       public Questions() {

          
           IsolatedStorageFile ISF = IsolatedStorageFile.GetUserStoreForApplication();
          

                   questions = new List<String>();
                   answeres = new List<Boolean>();

                   if (ISF.FileExists("Questions.xml")) {
                       IsolatedStorageFileStream isoStream = new IsolatedStorageFileStream("Questions.xml", FileMode.Open, FileAccess.Read, FileShare.Read, ISF);
                      
                       var qslist = from c in XElement.Load(isoStream).Element("Questions").Elements()  // Important we are loading from ISF updated from dropbox !!
                                  select c;
                       ISF.Dispose();
                       isoStream.Dispose();

                       foreach (var el in qslist)
                       {
                           this.questions.Add(el.Value);

                           if ((string)el.Attribute("answ") == "true")
                               this.answeres.Add(true);
                           else
                               this.answeres.Add(false);
                       }

                      
                       }
                   else
                   {
                       ISF.Dispose();
                       var qslist = from c in XElement.Load("Assets/Questions.xml").Element("Questions").Elements()
                                    select c;

                       foreach (var el in qslist)
                       {
                           this.questions.Add(el.Value);

                           if ((string)el.Attribute("answ") == "true")
                               this.answeres.Add(true);
                           else
                               this.answeres.Add(false);
                       }

                   }

                   
                   
           
              

           }
开发者ID:jcimoch,项目名称:SmartBrain,代码行数:53,代码来源:Questions.cs

示例7: Open_Click

  private void Open_Click(object sender, RoutedEventArgs e)
  {
      if (Files.SelectedItem != null)
      {
          app.Filename = (string)Files.SelectedItem;
          using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
          {
              IsolatedStorageFileStream location = new IsolatedStorageFileStream(app.Filename,
                System.IO.FileMode.Open, storage);
              System.IO.StreamReader file = new System.IO.StreamReader(location);
              app.Content = file.ReadToEnd();
              file.Dispose();
              location.Dispose();
          }
      NavigationService.GoBack();
 
      }
  }
开发者ID:Thejas007,项目名称:Phone-Xap,代码行数:18,代码来源:OpenPage.xaml.cs

示例8: ws_GetThongBaoDonCompleted

 void ws_GetThongBaoDonCompleted(object sender, GetThongBaoDonCompletedEventArgs e)
 {
     if (e.Result != "")
     {
         //Load thong bao len RichEidit
         IsolatedStorageFileStream fs = new IsolatedStorageFileStream("Temp.doc", FileMode.OpenOrCreate, FileAccess.ReadWrite, str);
         BinaryWriter br = new BinaryWriter(fs);
         br.Write(Convert.FromBase64String(e.Result));
         richEdit.LoadDocument(fs, DocumentFormat.Doc);
         this.Title = tieude;
         fs.Close();
         fs.Dispose();
     }
     else
     {
         richEdit.Text = "Nội dung thông báo trống";
     }
 }
开发者ID:puentepr,项目名称:thuctapvietinsoft,代码行数:18,代码来源:ViewAnnouncement.xaml.cs

示例9: decode

 private void decode(object sender, RoutedEventArgs e)
 {
     IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication();
     LibmadWrapper Libmad = new LibmadWrapper();
     
     IBuffer buffer = WindowsRuntimeBufferExtensions.AsBuffer(Mp3bytes, 0, Mp3bytes.Length);
     PCMStream = isf.CreateFile("decoded_pcm.pcm");
    
     bool init = Libmad.DecodeMp32Pcm_Init(buffer);
     if (init)
     {
         List<short> samples = new List<short>();
         RawPCMContent rpcc = null;
         try
         {
             while ((rpcc = Libmad.ReadSample()).count != 0)
             {
                 short[] shortBytes = rpcc.PCMData.ToArray<short>();
                 byte[] rawbytes = new byte[shortBytes.Length * 2];
                 for (int i = 0; i < shortBytes.Length; i++)
                 {
                     rawbytes[2 * i] = (byte)shortBytes[i];
                     rawbytes[2 * i + 1] = (byte)(shortBytes[i] >> 8);
                 }
                  PCMStream.Write(rawbytes, 0, rawbytes.Length);
             }
             PCMStream.Flush();
             PCMStream.Close();
             PCMStream.Dispose();
             MessageBox.Show("over");
             Libmad.CloseFile();    
         }
         catch (Exception exception)
         {
             MessageBox.Show(exception.Message);
         }
     }
     isf.Dispose();
 }
开发者ID:sandcu,项目名称:wpaudio,代码行数:39,代码来源:MainPage.xaml.cs

示例10: GetCurrentLeaveEntries

        public static Collection<LeaveEntry> GetCurrentLeaveEntries()
        {
            IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication();

            if (storage.FileExists("LeaveRecords.xml"))
            {
                IsolatedStorageFileStream location = new IsolatedStorageFileStream("LeaveRecords.xml", System.IO.FileMode.Open, storage);
                System.IO.StreamReader file = new System.IO.StreamReader(location);
                XmlSerializer serializer = new XmlSerializer(typeof(Collection<LeaveEntry>));

                Collection<LeaveEntry> entries = (Collection<LeaveEntry>)serializer.Deserialize(file);

                file.Dispose();
                location.Dispose();

                return entries;
            }
            else
            {
                return new Collection<LeaveEntry>();
            }
        }
开发者ID:DragonRiderIL,项目名称:LeaveBalancerRepo,代码行数:22,代码来源:PayPeriodUtilities.cs

示例11: PorpAllSourcesToDb

        public void PorpAllSourcesToDb(ICollection<FeedSource> allFeedSources)
        {
            using (var store = IsolatedStorageFile.GetUserStoreForApplication())
              {
            var stream = new IsolatedStorageFileStream("test.txt",
                                                        System.IO.FileMode.Create,
                                                        System.IO.FileAccess.Write,
                                                        store);
            try
            {
              FeedSourceCollection allSourcesCollection = new FeedSourceCollection();
              allSourcesCollection.Items = new List<FeedSource>(allFeedSources);

              XmlSerializer serializer = new XmlSerializer(typeof(FeedSourceCollection));
              serializer.Serialize(stream, allSourcesCollection);
            }
            finally
            {
              stream.Close();
              stream.Dispose();
            }
              }
        }
开发者ID:bill-mybiz,项目名称:old_DoinIt-WP7-Feed-Reader,代码行数:23,代码来源:SimpleIsolatedStorageDataPersister.cs

示例12: ApplicationBarIconButton_Click

        private void ApplicationBarIconButton_Click(object sender, EventArgs e)
        {
            System.IO.IsolatedStorage.IsolatedStorageFile storage = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication();

            using (storage)
            {
                XDocument _doc = new XDocument();
                XElement baseSetting = new XElement("BaseSetting");
                XAttribute AnnualBalance = new XAttribute("AnnualBalance", this.AnnualBalance.Text);
                XAttribute SickBalance = new XAttribute("SickBalance", this.SickBalance.Text);
                XAttribute AnnualAccrue = new XAttribute("AnnualAccrue", this.AnnualAccrue.Text);
                XAttribute SickAccrue = new XAttribute("SickAccrue", this.SickAccrue.Text);
                XAttribute PayPeriod = new XAttribute("PayPeriod", this.PayPeriodBase.Text);
                baseSetting.Add(AnnualBalance, SickBalance, AnnualAccrue, SickAccrue, PayPeriod);
                _doc = new XDocument(new XDeclaration("1.0", "utf-8", "yes"), baseSetting);
                IsolatedStorageFileStream location = new IsolatedStorageFileStream("LeaveSettings.xml", FileMode.Create, storage);
                StreamWriter file = new StreamWriter(location);
                _doc.Save(file);
                file.Dispose();
                location.Dispose();
                NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
            }
        }
开发者ID:DragonRiderIL,项目名称:LeaveBalancerRepo,代码行数:23,代码来源:SettingsPage.xaml.cs

示例13: GetBaseValues

        public static Basis GetBaseValues()
        {
            using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
            {
                Basis baseValues = new Basis();

                XElement _xml;
                IsolatedStorageFileStream location = new IsolatedStorageFileStream(@"LeaveSettings.xml", System.IO.FileMode.Open, storage);
                System.IO.StreamReader file = new System.IO.StreamReader(location);
                _xml = XElement.Parse(file.ReadToEnd());
                if (_xml.Name.LocalName != null)
                {
                    baseValues.StartingAnnual = double.Parse(_xml.Attribute("AnnualBalance").Value);
                    baseValues.StartingSick = double.Parse(_xml.Attribute("SickBalance").Value);
                    baseValues.AnnualAccrue = double.Parse(_xml.Attribute("AnnualAccrue").Value);
                    baseValues.SickAccrue = double.Parse(_xml.Attribute("SickAccrue").Value);
                    baseValues.StartingPayPeriod = DateTime.Parse(_xml.Attribute("PayPeriod").Value);
                }
                file.Dispose();
                location.Dispose();

                return baseValues;
            }
        }
开发者ID:DragonRiderIL,项目名称:LeaveBalancerRepo,代码行数:24,代码来源:PayPeriodUtilities.cs

示例14: LoadDataFromStore

        private void LoadDataFromStore()
        {
            IsolatedStorageFileStream isStream = null;

            try
            {
                lock (store)
                {
                    isStream = new IsolatedStorageFileStream(storageAreaName + @"\" + itemsFileName, FileMode.Open, FileAccess.Read, FileShare.None, store);

                    using (StreamReader reader = new StreamReader(isStream))
                    {
                        if (!reader.EndOfStream)
                        {
                            items = (List<ItemModel>)serializer.Deserialize(reader);
                        }
                    } // this should implicitly dispose of isStream too
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                if (items == null)
                    items = new List<ItemModel>();
                if (isStream != null)
                    isStream.Dispose();
            }
        }
开发者ID:yadyn,项目名称:ItsBeen,代码行数:30,代码来源:IsolatedStorageItemService.cs

示例15: appBarBtnFav_Click

        private void appBarBtnFav_Click(object sender, System.EventArgs e)
        {
            using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
            {
                try
                {
                    IsolatedStorageFileStream location;
                    if (!storage.FileExists("favoriteRoutes.dat"))
                    {
                        location = new IsolatedStorageFileStream("favoriteRoutes.dat", System.IO.FileMode.CreateNew, storage); 
                        location.Dispose();
                    }

                    location = new IsolatedStorageFileStream("favoriteRoutes.dat", System.IO.FileMode.Open, storage);
                    string strTemp = WebService.GetCity() + "," + m_strStart + "," + m_strEnd + ";";
                    StreamReader sr = new StreamReader(location);
                    string content = sr.ReadToEnd();
                    sr.Close();
                    location.Dispose();  
                    if (content.Contains(strTemp))
                    {
                        MessageBox.Show("已收藏");
                    }
                    else 
                    {
                        location = new IsolatedStorageFileStream("favoriteRoutes.dat", System.IO.FileMode.Append, storage);
                        StreamWriter sw = new StreamWriter(location);
                        sw.Write(strTemp);
                        sw.Close();
                        MessageBox.Show("收藏成功");
                        location.Dispose();
                    } 
                }
                catch (Exception e1)
                {
                    Debug.WriteLine(e1.Message);
                }

            }
        }
开发者ID:zongjingyao,项目名称:WP8-OnlineBus,代码行数:40,代码来源:RouteDetailPage.xaml.cs


注:本文中的System.IO.IsolatedStorage.IsolatedStorageFileStream.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。