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


C# IsolatedStorageFile.OpenFile方法代码示例

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


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

示例1: GetFile

 private static void GetFile(IsolatedStorageFile istorage, string filename, Action<File> returns)
 {
     using (var openedFile = istorage.OpenFile(filename, System.IO.FileMode.Open))
     {
         ReadFileFromOpenFile(filename, openedFile, returns);
     }
 }
开发者ID:halllo,项目名称:SilverlightRun,代码行数:7,代码来源:IsolatedFiles.cs

示例2: IsolatedStorageTracer

 public IsolatedStorageTracer()
 {
     _storageFile = IsolatedStorageFile.GetUserStoreForApplication();
     _storageFileStream = _storageFile.OpenFile("MagellanTrace.log", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);
     _streamWriter = new StreamWriter(_storageFileStream);
     _streamWriter.AutoFlush = true;
 }
开发者ID:p69,项目名称:magellan-framework,代码行数:7,代码来源:Tracer.cs

示例3: Save

        private void Save()
        {
            store = IsolatedStorageFile.GetUserStoreForApplication();

            IsolatedStorageFileStream stream = store.OpenFile(filterFilename, FileMode.Truncate);
            if (null != stream)
            {
                DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(FilterViewModel));
                ser.WriteObject(stream, App.ViewModelFilter);
                stream.Close();
            }
        }
开发者ID:klzig,项目名称:WarmShowers-Windows,代码行数:12,代码来源:Filter.cs

示例4: ReadTextFile

 protected static string ReadTextFile(IsolatedStorageFile isf, string path)
 {
     string text;
     using (var fileStream = isf.OpenFile(path, FileMode.Open))
     {
         using (StreamReader sr = new StreamReader(fileStream))
         {
             text = sr.ReadToEnd();
         }
     }
     return text;
 }
开发者ID:slodge,项目名称:main,代码行数:12,代码来源:BaseViewModel.cs

示例5: CCUserDefault

    /**
     * implements of CCUserDefault
     */
    private CCUserDefault()
    {
        myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication();

        // only create xml file once if it doesnt exist
        if ((!isXMLFileExist())) {
            createXMLFile();
        }

        using (IsolatedStorageFileStream fileStream = myIsolatedStorage.OpenFile(XML_FILE_NAME, FileMode.Open, FileAccess.Read)) {
            parseXMLFile(fileStream);
        }
    }
开发者ID:homocury,项目名称:cocos2d-xna,代码行数:16,代码来源:CCUserDefault.cs

示例6: OpenLogFile

        private static Stream OpenLogFile(IsolatedStorageFile store)
        {
            if (Profile == null)
            {
                return Stream.Null;
            }

            try
            {
                var fileName = string.Format(LOGFILE_TEMPLATE, DateTime.UtcNow.ToString("yyyy-MM-dd"));
                var folderPath = Path.Combine(Profile.CurrentProfilePath(), LOGFOLDER);

                if (!store.DirectoryExists(folderPath))
                {
                    store.CreateDirectory(folderPath);
                }

                var filePath = Path.Combine(folderPath, fileName);

                if (store.FileExists(filePath))
                {
                    return store.OpenFile(filePath, FileMode.Append);
                }
                else
                {
                    CleanupLogs(store, folderPath);

                    return store.OpenFile(filePath, FileMode.Create);
                }
            }
            catch (Exception ex)
            {
                // Logging Failed, don't kill the process because of it
                Debugger.Break();

                return Stream.Null;
            }
        }
开发者ID:SNSB,项目名称:DiversityMobile,代码行数:38,代码来源:LogFile.cs

示例7: CopyToIsolatedStorage

        private static void CopyToIsolatedStorage(string file, IsolatedStorageFile store, bool overwrite = true)
        {
            if (store.FileExists(file) && !overwrite)
                return;

            using (Stream resourceStream = Application.GetResourceStream(new Uri(file, UriKind.Relative)).Stream)
            using (IsolatedStorageFileStream fileStream = store.OpenFile(file, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite))
            {
                int bytesRead;
                var buffer = new byte[resourceStream.Length];
                while ((bytesRead = resourceStream.Read(buffer, 0, buffer.Length)) > 0)
                    fileStream.Write(buffer, 0, bytesRead);
            }
        }
开发者ID:jonnohuang,项目名称:projects,代码行数:14,代码来源:MainPage.xaml.cs

示例8: getThumbnail

        private BitmapImage getThumbnail(string file, IsolatedStorageFile iso)
        {
            BitmapImage bmp = new BitmapImage();

            if (iso.FileExists(file))
            {
                using (IsolatedStorageFileStream stream = iso.OpenFile(file, FileMode.Open, FileAccess.Read))
                {
                    bmp.SetSource(stream);
                }
            }
            else
                bmp = null;

            return bmp;
        }
开发者ID:UWbadgers16,项目名称:PhotoEnhancement,代码行数:16,代码来源:AllPhotos.xaml.cs

示例9: Load

        private void Load()
        {
            store = IsolatedStorageFile.GetUserStoreForApplication();

            IsolatedStorageFileStream stream = store.OpenFile(filterFilename, FileMode.OpenOrCreate);
            if (null != stream)
            {
                DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(FilterViewModel));
                App.ViewModelFilter = (FilterViewModel)ser.ReadObject(stream);
                stream.Close();

                if (null == App.ViewModelFilter)
                {   // First time app was run since installation
                    App.ViewModelFilter = new FilterViewModel();
                }
            }
        }
开发者ID:klzig,项目名称:WarmShowers-Windows,代码行数:17,代码来源:Filter.cs

示例10: ReadStoryFile

        /// <summary>
        /// 读取指定的story.
        /// </summary>
        /// <param name="storyName">story名称.</param>
        /// <param name="userStore">如果参数为null, 创建一个新的.</param>
        internal static void ReadStoryFile(string storyName, IsolatedStorageFile userStore = null)
        {
            if (userStore == null)
            {
                userStore = IsolatedStorageFile.GetUserStoreForApplication();
            }
            using (IsolatedStorageFileStream fileStream = userStore.OpenFile(storyName + ".xml", System.IO.FileMode.Open))
            {
                XDocument xdoc = XDocument.Load(fileStream);
                var picturesLibrary = new MediaLibrary().Pictures;

                // Load all photos.
                foreach (XElement photoElement in xdoc.Root.Elements())
                {
                    try
                    {
                        Photo photo = new Photo()
                        {
                            Name = photoElement.Attribute("Name").Value,
                        };
                        string photoDurationString = photoElement.Attribute("PhotoDuration").Value;
                        int photoDuration = int.Parse(photoDurationString);
                        photo.PhotoDuration = TimeSpan.FromSeconds(photoDuration);
                        XElement transitionElement = photoElement.Element("Transition");
                        if (transitionElement != null)
                        {
                            photo.Transition = TransitionBase.Load(photoElement.Element("Transition"));
                        }
                        Picture picture = picturesLibrary.Where(p => p.Name == photo.Name).FirstOrDefault();
                        if (picture == null)
                        {
                            // 如果找不到原文件,可能已经被删除了
                            // TODO: 我们需要记录错误吗? 我们是继续下一个图片还是抛出异常?
                            continue;
                        }
                        photo.ThumbnailStream = picture.GetThumbnail();
                        App.MediaCollection.Add(photo);
                    }
                    catch
                    {
                        // TODO: 我们需要记录错误吗? 我们是继续下一个图片还是抛出异常?
                        continue;
                    }
                }
            }
        }
开发者ID:zealoussnow,项目名称:OneCode,代码行数:51,代码来源:PersistenceHelper.cs

示例11: signInButton_SessionChanged_1

        private void signInButton_SessionChanged_1(object sender, Microsoft.Live.Controls.LiveConnectSessionChangedEventArgs e)
        {
            if (e.Status != LiveConnectSessionStatus.Connected)
                return;


            manager.AllRoadMapsReceived += (o, eventAllRoadMaps) =>
            {
                if (eventAllRoadMaps.RoadMaps.Count  == 0)
                {
                    Debug.WriteLine("Aucun rendez-vous n'existe pour les jours sélectionnés");
                    return;
                }

                try
                {
                    //SaveTableur();
                    SpreadSheetRoadmapGenerator.GenerateXLS("feuilles-de-route.xlsx", eventAllRoadMaps.RoadMaps, 5.5f, 1.6f);
                    if (e.Session != null && e.Status == LiveConnectSessionStatus.Connected)
                    {
                        myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication();
                        fileStream = myIsolatedStorage.OpenFile("feuilles-de-route.xlsx", FileMode.Open, FileAccess.Read);
                        reader = new StreamReader(fileStream);
                        App.Session = e.Session;
                        LiveConnectClient client = new LiveConnectClient(e.Session);
                        client.UploadCompleted += client_UploadCompleted;
                        client.UploadAsync("me/skydrive", "feuilles-de-route.xlsx", reader.BaseStream, OverwriteOption.Overwrite);
                    }
                }
                catch (Exception exception)
                {
                    Debug.WriteLine(exception.Message);
                }
            };
            ReferenceMeeting start = new ReferenceMeeting(new DateTime(2013, 1, 2, 8, 30, 0), new Location()
            {
                Latitude = 48.85693,
                Longitude = 2.3412
            }) { City = "Paris", Subject = "Start" };
            ReferenceMeeting end = start;
            end.Subject = "End";

            manager.GetAllRoadMapsAsync(new DateTime(2013, 1, 2), new DateTime(2013, 2, 10), start, end);

        }
开发者ID:BenJoyenConseil,项目名称:planmyway,代码行数:45,代码来源:PivotPage1.xaml.cs

示例12: CCUserDefault

    /**
     * implements of CCUserDefault
     */
    private CCUserDefault()
    {
        #if WINDOWS || MACOS || LINUX
        // only create xml file once if it doesnt exist
        if ((!isXMLFileExist())) {
            createXMLFile();
        }
        using (FileStream fileStream = new FileInfo(XML_FILE_NAME).OpenRead()){
            parseXMLFile(fileStream);
        }
        #else
        myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication();

        // only create xml file once if it doesnt exist
        if ((!isXMLFileExist())) {
            createXMLFile();
        }

        using (IsolatedStorageFileStream fileStream = myIsolatedStorage.OpenFile(XML_FILE_NAME, FileMode.Open, FileAccess.Read)) {
            parseXMLFile(fileStream);
        }
        #endif
    }
开发者ID:eickegao,项目名称:cocos2d-xna,代码行数:26,代码来源:CCUserDefault.cs

示例13: LoadRepos

        private void LoadRepos(IsolatedStorageFile iso)
        {
            if (!iso.FileExists(RepoFilename))
                return;

            try
            {
                using (var stream = iso.OpenFile(RepoFilename, FileMode.Open, FileAccess.Read))
                using (var br = new BinaryReader(stream))
                {
                    var fileVer = br.ReadInt32();
                    var numContexts = br.ReadInt32();
                    for (int i = 0; i < numContexts; i++)
                    {
                        var login = br.ReadString();
                        foreach (var context in Contexts)
                        {
                            if (context.User.Login.Equals(login))
                            {
                                var numMyRepos = br.ReadInt32();
                                context.Repositories.Clear();
                                for (int j = 0; j < numMyRepos; j++)
                                {
                                    var repo = new Repo();
                                    repo.Load(br, fileVer);
                                    context.Repositories.Add(repo);
                                }
                                break;
                            }
                        }
                    }

                    br.Close();
                }
            }
            catch (EndOfStreamException)
            {
                iso.DeleteFile(RepoFilename);
            }
        }
开发者ID:quandtm,项目名称:Milestone,代码行数:40,代码来源:GitHubModel.cs

示例14: saveImageToCache

        private static void saveImageToCache(ExtendedImage image, string filename, IsolatedStorageFile storage)
        {
            try
            {
                using (IsolatedStorageFileStream cachedFile = storage.OpenFile(filename, FileMode.Create))
                {
                    WriteableBitmap bitmap = ImageExtensions.ToBitmap(image);
                    bitmap.SaveJpeg(cachedFile, bitmap.PixelWidth, bitmap.PixelHeight, 0, 80);

#if DEBUG
                    App.logger.log("Created cached file {0}", filename);
#endif
                }
            }
            catch (Exception)
            {
#if DEBUG
                throw;
#endif
            }
        }
开发者ID:TheInterframe,项目名称:SparklrWP-OLD,代码行数:21,代码来源:Image.cs

示例15: LoadAuth

        private void LoadAuth(IsolatedStorageFile isoStore)
        {
            if (isoStore.FileExists(AuthFilename))
            {
                try
                {
                    using (var stream = isoStore.OpenFile(AuthFilename, FileMode.Open, FileAccess.Read))
                    using (var br = new BinaryReader(stream))
                    {
                        var fileVer = br.ReadInt32();
                        var unameLen = br.ReadInt32();
                        var unameEncrypted = br.ReadBytes(unameLen);
                        var pwordLen = br.ReadInt32();
                        var pwordEncrypted = br.ReadBytes(pwordLen);
                        var unamePlain = ProtectedData.Unprotect(unameEncrypted, null);
                        var pwordPlain = ProtectedData.Unprotect(pwordEncrypted, null);
                        _username = System.Text.Encoding.UTF8.GetString(unamePlain, 0, unamePlain.Length);
                        _password = System.Text.Encoding.UTF8.GetString(pwordPlain, 0, pwordPlain.Length);
                        IsAuthenticated = true;
                        InitAuth(_username, _password);

                        var numContexts = br.ReadInt32();
                        Contexts.Clear();
                        for (int i = 0; i < numContexts; i++)
                        {
                            var usr = new User();
                            usr.Load(br, fileVer);
                            Contexts.Add(new Context() { User = usr });
                        }
                        AuthenticatedUser = Contexts[0].User;

                        br.Close();
                    }
                }
                catch (EndOfStreamException)
                {
                    isoStore.DeleteFile(AuthFilename);
                }
            }
            else
            {
                IsAuthenticated = false;
            }
        }
开发者ID:quandtm,项目名称:Milestone,代码行数:44,代码来源:GitHubModel.cs


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