• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# IsolatedStorage.IsolatedStorageFileStream类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: ReadTextFile

        protected override string ReadTextFile(string filename)
        {
            String result = null;

            try
            {

                using (var isoStore = IsolatedStorageFile.GetStore(Scope, null, null))
                {

                    if (isoStore.FileExists(filename))
                    {
                        using (var stream = new IsolatedStorageFileStream(filename, FileMode.Open, isoStore))
                        {
                            long length = stream.Length;

                            StreamReader reader = new StreamReader(stream);
                            result = reader.ReadToEnd();
                        }
                    }
                }

            }
            catch (Exception)
            {
                //log.Error("Cannot read application settings from isolated storage file", e);
            }

            return result;
        }
开发者ID:iejeecee,项目名称:mediaviewer,代码行数:30,代码来源:IsolatedStorageSettingsStore.cs


示例17: InjectScript

        public void InjectScript()
        {
            using(IsolatedStorageFileStream file = new IsolatedStorageFileStream("debugOutput.txt", FileMode.Create, FileAccess.Write, IsolatedStorageFile.GetUserStoreForApplication()))
            {
            }

            if (!hasListener)
            {
                PhoneApplicationService.Current.Closing += OnServiceClosing;
                hasListener = true;
            }


            string script = @"(function(win) {
        function exec(msg) { window.external.Notify('ConsoleLog/' + msg); }
        var cons = win.console = win.console || {};
        cons.log = exec;
        cons.debug = cons.debug || cons.log;
        cons.info = cons.info   || function(msg) { exec('INFO:' + msg ); };     
        cons.warn = cons.warn   || function(msg) { exec('WARN:' + msg ); };
        cons.error = cons.error || function(msg) { exec('ERROR:' + msg ); };
    })(window);";

            Browser.InvokeScript("execScript", new string[] { script });
        }
开发者ID:0xack13,项目名称:AlwirdAlatif,代码行数:25,代码来源:ConsoleHelper.cs


示例18: SlowkaClass

        public SlowkaClass()
        {
            slowka = new List<Slowko>();
            XDocument doc = null;
            IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication();
            IsolatedStorageFileStream storageStream = null;

            if(storage.FileExists("slowka.xml"))
            {
                storageStream = new IsolatedStorageFileStream("slowka.xml", System.IO.FileMode.Open, FileAccess.Read, storage);
                doc = XDocument.Load(storageStream);
                storageStream.Close();
            }
            else
            {
                doc = XDocument.Load("slowka.xml");
                storageStream = new IsolatedStorageFileStream("slowka.xml", System.IO.FileMode.CreateNew, FileAccess.Write, storage);
                doc.Save(storageStream);
                storageStream.Close();

            }

            //var vSlowka = from s in XElement.Load("slowka.xml").Element("slowko").Elements() select s;
            var v = from s in doc.Descendants("slowko") select new Slowko(s);

            slowka.AddRange(v);
        }
开发者ID:KLamkiewicz,项目名称:WindowsPhoneApp1,代码行数:27,代码来源:SlowkaClass.cs


示例19: btnLeLog_Click

        private void btnLeLog_Click(object sender, RoutedEventArgs e)
        {
            mut.WaitOne();//Espera até a thread poder trabalhar ( acessar nosso recurso .txt );

            IsolatedStorageFile isoFile = IsolatedStorageFile.GetUserStoreForApplication();

            if (!isoFile.DirectoryExists("/Logs/"))
            {
                mut.ReleaseMutex();// Liebro o meu mutex
                MessageBox.Show("Nenhum log foi encontrado");
                return;
            }
           
                IsolatedStorageFileStream isoLogFileStream = new IsolatedStorageFileStream(
                "\\Logs\\MeuLog.txt",
                System.IO.FileMode.Open,
                isoFile);

                StreamReader reader = new StreamReader(isoLogFileStream);
                string log = reader.ReadToEnd();

                //Liberar todos os recursos
                isoLogFileStream.Close();
                reader.Close();

                // Liebro o meu mutex
                mut.ReleaseMutex();

                MessageBox.Show(log);
            
        }
开发者ID:dmourainatel,项目名称:Windows-Phone-Projects,代码行数:31,代码来源:MainPage.xaml.cs


示例20: SetSourceStr

 private void SetSourceStr(string sourceStr)
 {
     if (imageCache.ContainsKey(sourceStr) == true)
     {
         SourceImage.Source = imageCache[sourceStr];
     }
     else
     {
         using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
         {
             if (isf.FileExists(sourceStr) == false)
             {
                 SourceImage.Source = null;
             }
             else
             {
                 BitmapImage source = new BitmapImage();
                 using (IsolatedStorageFileStream isfStream = new IsolatedStorageFileStream(sourceStr, System.IO.FileMode.Open, isf))
                 {
                     source.SetSource(isfStream);
                 }
                 imageCache.Add(sourceStr, source);
                 SourceImage.Source = source;
             }
         }
     }
 }
开发者ID:vapps,项目名称:Pisa,代码行数:27,代码来源:ImageEx.xaml.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IsolatedStorage.IsolatedStorageSettings类代码示例发布时间:2022-05-26
下一篇:
C# IsolatedStorage.IsolatedStorageFile类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap