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


C# IsolatedStorage.IsolatedStorageFileStream类代码示例

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


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

示例1: Image_Tap

 private void Image_Tap(object sender, GestureEventArgs e)
 {
     var file = (RingtoneListItem)((Image)sender).DataContext;
     if (file != null && !file.DisplayName.Contains("none"))
     {
     #if ARM
         string fileName = Path.GetFileName(file.FullPath);
         try
         {
             // Copy file to the isf
             if (!_isoStore.FileExists(fileName))
             {
                 SystemTray.ProgressIndicator.IsVisible = true;
                 File.Copy(file.FullPath, Path.Combine(_isoRootPath, fileName), true);
             }
             using (IsolatedStorageFileStream isoStream = new IsolatedStorageFileStream(fileName, FileMode.Open, _isoStore))
             {
                 mediaElement.SetSource(isoStream);
                 mediaElement.Play();
                 SystemTray.ProgressIndicator.IsVisible = false;
             }
         }
         catch { }
     #else
         MessageBox.Show(file.FullPath);
     #endif
     }
 }
开发者ID:sensboston,项目名称:WPTweaker,代码行数:28,代码来源:RingtoneChooser.xaml.cs

示例2: cbLiveTile_Click

        private void cbLiveTile_Click(object sender, RoutedEventArgs e)
        {
            if (cbLiveTile.IsChecked.Value)
            {
                IsolatedStorageFile directory = IsolatedStorageFile.GetUserStoreForApplication();
                if (directory.FileExists("settings.txt"))
                {
                    using (var myFilestream = new IsolatedStorageFileStream("settings.txt", FileMode.Truncate, IsolatedStorageFile.GetUserStoreForApplication()))
                    using (var writer = new StreamWriter(myFilestream))
                    {
                        writer.Write("1");
                    }
                }

                CreateLiveTile();        
            }
            else
            {
                IsolatedStorageFile directory = IsolatedStorageFile.GetUserStoreForApplication();
                if (directory.FileExists("settings.txt"))
                {
                    using (var myFilestream = new IsolatedStorageFileStream("settings.txt", FileMode.Truncate, IsolatedStorageFile.GetUserStoreForApplication()))
                    using (var writer = new StreamWriter(myFilestream))
                    {
                        writer.Write("0");
                    }
                }

                ResetMainTile(); 
            }
        }
开发者ID:BinaryWasteland,项目名称:ClientContactInformation-WP7,代码行数:31,代码来源:Settings.xaml.cs

示例3: RetrieveAccessToken

        public static Yammer.OAuthToken RetrieveAccessToken()
        {
            string key;

            IsolatedStorageFile myStore = IsolatedStorageFile.GetUserStoreForApplication();

            using (var isoFileStream = new IsolatedStorageFileStream("key.txt", FileMode.OpenOrCreate, myStore))
            {
                using (var isoFileReader = new StreamReader(isoFileStream))
                {
                    key = isoFileReader.ReadToEnd();
                }
            }

            if (string.IsNullOrWhiteSpace(key))
                return null;

            var keyParts = key.Split('&');
            if (keyParts.Length != 2)
                return null;

            if (string.IsNullOrWhiteSpace(keyParts[0]))
                return null;

            if (string.IsNullOrWhiteSpace(keyParts[1]))
                return null;

            return new Yammer.OAuthToken
            {
                Key = keyParts[0],
                Secret = keyParts[1]
            };
        }
开发者ID:nahog,项目名称:Yammer-Hub,代码行数:33,代码来源:AccessTokenStorage.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: Main

        static void Main()
        {
            // Создание изолированного хранилища уровня .Net сборки.
            IsolatedStorageFile userStorage = IsolatedStorageFile.GetUserStoreForAssembly();

            // Создание файлового потока с указанием: Имени файла, FileMode, объекта хранилища.
            IsolatedStorageFileStream userStream = new IsolatedStorageFileStream("UserSettings.set", FileMode.Create, userStorage);

              //   StreamWriter - запись данных в поток userStream.
            StreamWriter userWriter = new StreamWriter(userStream);
            userWriter.WriteLine("User Prefs");
            userWriter.Close();

            // Проверить, если файл существует.
            string[] files = userStorage.GetFileNames("UserSettings.set");

            if (files.Length == 0)
            {
                Console.WriteLine("No data saved for this user");
            }
            else
            {
                // Прочитать данные из потока.
                userStream = new IsolatedStorageFileStream("UserSettings.set", FileMode.Open, userStorage);

                StreamReader userReader = new StreamReader(userStream);
                string contents = userReader.ReadToEnd();
                Console.WriteLine(contents);
            }

            // Задержка.
            Console.ReadKey();
        }
开发者ID:vbre,项目名称:CS_2015_Winter,代码行数:33,代码来源:Program.cs

示例6: BeginDownloadXml

        public override IAsyncResult BeginDownloadXml(Uri feeduri, AsyncCallback callback)
        {
#if !WINDOWS_PHONE
            if (!IsolatedStorageFile.IsEnabled) throw new MissingFeedException("IsolatedStorage is not enabled! Cannot access files from IsolatedStorage!");
#endif


            try
            {
                using (var store = IsolatedStorageFile.GetUserStoreForApplication())
                {
                    if(!PingFeed(feeduri, store)) throw new MissingFeedException(string.Format("Could not find feed at location {0}", feeduri));

                    using (var stream = new IsolatedStorageFileStream(feeduri.OriginalString, FileMode.Open,
                                                                   FileAccess.Read, store))
                    {
                        using(var reader = new StreamReader(stream))
                        {
                            var strOutput = reader.ReadToEnd();
                            //Fake the async result
                            var result = new AsyncResult<FeedTuple>(callback, new FeedTuple { FeedContent = strOutput, FeedUri = feeduri }, true);
                            if (callback != null) callback.Invoke(result);
                            return result;
                        }
                    }
                }
            }
            catch (IsolatedStorageException ex)
            {
                throw new MissingFeedException(string.Format("Unable to open feed at {0}", feeduri), ex);
            }
        }
开发者ID:GuiBGP,项目名称:qdfeed,代码行数:32,代码来源:IsolatedStorageFeedFactory.cs

示例7: Main

        static void Main(string[] args)
        {
            IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForAssembly();

            IsolatedStorageFileStream isoFile = new IsolatedStorageFileStream("myfile.txt", FileMode.Create, isoStore);
            Console.WriteLine(isoFile.GetType().GetField("m_FullPath", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(isoFile).ToString());

            StreamWriter sw = new StreamWriter(isoFile);

            sw.WriteLine("This text is written to an isolated storage file.");

            sw.Close();
            isoFile.Close();


            isoFile = new IsolatedStorageFileStream("myfile.txt", FileMode.Open, isoStore);


            StreamReader sr = new StreamReader(isoFile);

            Console.WriteLine(sr.ReadToEnd());

            sr.Close();
            isoFile.Close();
        }
开发者ID:oblivious,项目名称:Oblivious,代码行数:25,代码来源:Program.cs

示例8: ReadDataFromIsolatedStorage

        public static ObservableCollection<FileViewModel> ReadDataFromIsolatedStorage()
        {
            ObservableCollection<FileViewModel> obsColFiles = new ObservableCollection<FileViewModel>();

            using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
            {
                if (!storage.FileExists(FilePath))
                {
                    return obsColFiles;
                }

                using (var isoFileStream = new IsolatedStorageFileStream(FilePath, FileMode.OpenOrCreate, storage))
                {
                    using (XmlReader reader = XmlReader.Create(isoFileStream))
                    {

                        XDocument xml = XDocument.Load(reader);

                        foreach (var file in xml.Root.Elements("File"))
                        {
                            Guid id;

                            Guid.TryParse(file.Attribute("Id").Value, out id);
                            string description = file.Attribute("Description").Value;

                            obsColFiles.Add(new FileViewModel { Description = description, Id = id, IsNew = false });
                        }

                        return obsColFiles;
                    }
                }
            }
        }
开发者ID:bdetchison,项目名称:WP7SkyDriveIntegration,代码行数:33,代码来源:File3Dal.cs

示例9: LoadTasks

 protected override void LoadTasks()
 {
     var file = IsolatedStorageFile.GetUserStoreForAssembly();
     _tasks = null;
     using(var stream = new IsolatedStorageFileStream(
         TasksFileName, FileMode.OpenOrCreate, FileAccess.Read, file))
     {
         var reader = new XmlTextReader(stream);
         var serializer = new XmlSerializer(typeof(List<Task>));
         try
         {
             _tasks= serializer.Deserialize(reader) as List<Task>;
         }
         catch (Exception)
         {
             _tasks = new List<Task>();
         }
         finally
         {
             reader.Close();
         }
         if (_tasks.Count == 0)
             _lastId = 0;
         else
             _lastId = _tasks.Max(t => t.TaskId);
     }
 }
开发者ID:gartdan,项目名称:StopForgetting,代码行数:27,代码来源:IsolatedStorageTaskStore.cs

示例10: SaveId

        static bool SaveId()
        {
            try
            {
#if !OOB
                using (IsolatedStorageFile storageFile = IsolatedStorageFile.GetUserStoreForApplication())
                {
                    using (IsolatedStorageFileStream storageStream = new IsolatedStorageFileStream(StorageFileName, System.IO.FileMode.Create, storageFile))
                    {
                        System.IO.StreamWriter writer = new System.IO.StreamWriter(storageStream);
                        // write settings to isolated storage
                        writer.WriteLine(instanceIdGuid.Value.ToString());
                        writer.Flush();
                    }

                    return true;
                }
#else
                if (IsolatedStorageSettings.ApplicationSettings.Contains(StorageKey))
                {
                    IsolatedStorageSettings.ApplicationSettings[StorageKey] = instanceIdGuid.Value.ToString();
                }
                else
                {
                    IsolatedStorageSettings.ApplicationSettings.Add(StorageKey, instanceIdGuid.Value.ToString());
                }
                return true;
#endif
            }
            catch
            {
                // users can disable isolated storage
                return false;
            }
        }
开发者ID:rhlbenjamin,项目名称:azure-media-services-samples,代码行数:35,代码来源:InstanceDataClient.cs

示例11: Load

 public static IList<string> Load(string StorageFileName)
 {
     List<string> result = new List<string>();
     try
     {
         IsolatedStorageFile storageFile = IsolatedStorageFile.GetUserStoreForApplication();
         if (storageFile.FileExists(StorageFileName))
         {
             using (IsolatedStorageFileStream storageStream = new IsolatedStorageFileStream(
                 StorageFileName, System.IO.FileMode.Open, storageFile))
             {
                 using (System.IO.StreamReader reader = new System.IO.StreamReader(storageStream))
                 {
                     // read settings from isolated storage
                     while (reader.EndOfStream == false)
                     {
                         result.Add(reader.ReadLine());
                     }
                 }
             }
         }
         return result;
     }
     catch
     {
         return result;
     }
 }
开发者ID:rhlbenjamin,项目名称:azure-media-services-samples,代码行数:28,代码来源:SavedListDataClient.cs

示例12: LoadState

        public PropertyFinderPersistentState LoadState()
        {
            PropertyFinderPersistentState state = null;

              try
              {
            // load from isolated storage
            using (var store = IsolatedStorageFile.GetUserStoreForApplication())
            using (var stream = new IsolatedStorageFileStream("data.txt",
                                  FileMode.OpenOrCreate, FileAccess.Read, store))
            using (var reader = new StreamReader(stream))
            {
              if (!reader.EndOfStream)
              {
            var serializer = new XmlSerializer(typeof(PropertyFinderPersistentState));
            state = (PropertyFinderPersistentState)serializer.Deserialize(reader);

            // set the persistence service for the newly loaded state
            state.PersistenceService = this;
              }
            }
              }
              catch
              {
              }

              // if we cannot retrieve the state, create a new state object
              if (state == null)
              {
            state = new PropertyFinderPersistentState(this);
              }

              return state;
        }
开发者ID:AlexanderGrant1,项目名称:PropertyCross,代码行数:34,代码来源:StatePersistenceService.cs

示例13: GetUserPreferences

 public static UserSettings GetUserPreferences()
 {
     IsolatedStorageFileStream fileStream = null;
     try
     {
         var fileLocation = IsolatedStorageFile.GetUserStoreForApplication();
         if (fileLocation.FileExists(FileSystem.SettingsFile))
         {
             fileStream = new IsolatedStorageFileStream(FileSystem.SettingsFile, FileMode.Open, fileLocation);
             var serializer = new XmlSerializer(typeof(UserSettings));
             var userSettings = (UserSettings)serializer.Deserialize(fileStream);
             if (userSettings != null)
             {
                 return userSettings;
             }
             else
             {
                 throw new Exception("Unable lo load user preferences");
             }
         }
         else
         {
             var settings = new UserSettings();
             UpdateUserSettings(settings);
             return settings;
         }
     }
     finally
     {
         if (fileStream!=null)
         {
             fileStream.Close();
         }
     }
 }
开发者ID:shahzadadil,项目名称:BirthdayReminderAndManager,代码行数:35,代码来源:SettingsUtility.cs

示例14: LoadIconPositions

        public static void LoadIconPositions()
        {
            try
            {
                using (var isoStore = IsolatedStorageFile.GetUserStoreForAssembly())
                using (var stream = new IsolatedStorageFileStream(IconPositionsFile, FileMode.Open, isoStore))
                using (var textStream = new StreamReader(stream))
                {
                    string line;
                    _desktopIconPositions = new Dictionary<string, Point>();

                    while ((line = textStream.ReadLine()) != null)
                    {
                        var items = line.Split(null, 3);
                        var point = new Point
                            {
                                X = Convert.ToInt32(items[0], CultureInfo.InvariantCulture),
                                Y = Convert.ToInt32(items[1], CultureInfo.InvariantCulture)
                            };

                        _desktopIconPositions.Add(items[2], point);
                    }
                }
            }

            catch (Exception ex)
            {
                Program.LogError(ex.Message);
                _desktopIconPositions = new Dictionary<string, Point>();
            }
        }
开发者ID:stephen-hill,项目名称:DeskDrive,代码行数:31,代码来源:Desktop.cs

示例15: RestoreFromFile

 private void RestoreFromFile(Stream file)
 {
         //
         //
         using (var store = IsolatedStorageFile.GetUserStoreForApplication()) {
                 using (var zip = new ZipInputStream(file)) {
                         try {
                                 while (true) {
                                         var ze = zip.GetNextEntry();
                                         if (ze == null) break;
                                         using (var f = new IsolatedStorageFileStream(ze.Name, FileMode.Create, store)) {
                                                 var fs = new byte[ze.Size];
                                                 zip.Read(fs, 0, fs.Length);
                                                 f.Write(fs, 0, fs.Length);
                                         }
                                 }
                         } catch {
                                 lblLastBackup.Text = StringResources.BackupAndRestorePage_Messages_RestoreFailed;
                                 App.ToastMe(StringResources.BackupAndRestorePage_Messages_RestoreFailed);
                                 return;
                         } finally {
                                 file.Close();
                                 ClearOldBackupFiles();
                                 App.ViewModel.IsRvDataChanged = true;
                         }
                 }
         }
         lblLastBackup.Text = StringResources.BackupAndRestorePage_Messages_RestoreSuccess;
         App.ToastMe(StringResources.BackupAndRestorePage_Messages_RestoreSuccess);
 }
开发者ID:tymiles003,项目名称:FieldService,代码行数:30,代码来源:BackupAndRestorePage.xaml.cs


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