Tag: isolatedstorage

如何为两个Windows窗体应用程序共享一个IsolatedStorage?

我在一个解决方案中有两个Windows窗体应用程序和库。 库类可以在IsolatedStorage中创建新文件夹和文件,并列出IsolatedStorage中的所有文件和文件夹。 第一个应用程序使用库类创建新文件夹/文件我希望第二个应用程序列出第一个应用程序创建的文件夹。 如何让他们使用相同的隔离存储?

如何在Windows Phone 8应用程序中解压缩IsolatedStorage中的文件?

在我的应用程序内,我试图一次下载大约180个小音频文件。 我尝试了BackgroundTransferService,但是对于这么多小文件它似乎并不稳定。 所以,现在我正在下载所有这些音频的ZIP,并希望在“audio”文件夹中提取它们。 我尝试了这个线程中的方法: 如何在Windows Phone 8中解压缩文件 但我收到此错误: ‘System.IO.IOException’ occurred in mscorlib.ni.dll…中’System.IO.IOException’ occurred in mscorlib.ni.dll…在以下代码中。 我怎样才能克服这个问题? while (reader.ReadInt32() != 101010256) { reader.BaseStream.Seek(-5, SeekOrigin.Current); // this line causes error }… 此外,我在哪里需要放置此代码,我在哪里给它目标目录? IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication(); using (IsolatedStorageFileStream fileStream = myIsolatedStorage.OpenFile(@”audio.rar”, FileMode.Open, FileAccess.ReadWrite)) { UnZipper unzip = new UnZipper(fileStream); foreach (string filename in unzip.FileNamesInZip()) { string FileName […]

从Windows Phone 7上的隔离存储打开JPEG时出现问题

脚本 应用程序打开 检查隔离存储中是否存在背景图像 如果没有,请从Web下载,并将其保存到隔离存储 从Isolated Storage中加载图像并将其设置为Panorama控件上的Background 问题 图像未加载到GUI中。当我检查从隔离存储器接收的字节数组时,它包含与最初写入的字节数相同的字节数,但图像未显示。 这是我正在尝试找出问题的一些测试代码: using (IsolatedStorageFile appStorage = IsolatedStorageFile.GetUserStoreForApplication()) { if (!appStorage.FileExists(@”default.jpg”)) { BitmapImage bmp = sender as BitmapImage; byte[] bytes = bmp.ConvertToBytes(); using (var inputfile = appStorage.CreateFile(@”default.jpg”)) { inputfile.Write(bytes, 0, bytes.Length); } } using (var isfs = appStorage.OpenFile(@”default.jpg”, FileMode.OpenOrCreate, FileAccess.Read)) { BitmapImage bmp = new BitmapImage(); bmp.SetSource(isfs); MainPanorama.Background = […]

位于PC上的WP7仿真器的隔离存储在哪里?

当我们使用模拟器并将文件存储在隔离存储中时。 文件实际存储在计算机上的哪个位置? 我的意思是路径。

为什么隔离存储不会在我的WP7应用程序中持续存在?

我正在为我的应用程序使用IsolatedStorageSettings.ApplicationSettings。 与隔离存储相关的所有代码都发生在我的Application_Launching,Application_Activated,Application_Closing和Application_Deactivated方法中,如下所示: public IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings; private void Application_Launching(object sender, LaunchingEventArgs e) { if (settings.Contains(“myObjList”)) { App.ObjList = (ObservableCollection)settings[“myObjList”]; } else { settings.Add(“myObjList”, App.ObjList); } } private void Application_Activated(object sender, ActivatedEventArgs e) { if (settings.Contains(“myObjList”)) { App.ObjList = (ObservableCollection)settings[“myObjList”]; } else { settings.Add(“myObjList”, App.ObjList); } } private void Application_Deactivated(object sender, DeactivatedEventArgs e) { settings[“myObjList”] […]

必须为此操作打开存储 – System.IO.Packaging.Package

我正在使用System.IO.Packaing.Package类来压缩文件。 在读取和保存文件的同时,可以让我的应用程序的多个实例同时运行。 当处理小文件时似乎都很好,但是当涉及大文件时,如果应用程序的两个实例同时保存,我会得到一个exception,消息Store必须打开,此操作的堆栈跟踪如下所示。 根据我的理解,当使用文件包 10mb时,将切换到IsolatedStorage。 考虑到这一点,我能够发现,即使这些是多个实例运行,它们都可以解决相同的隔离存储位置,我相信这就是问题所在。我能够找到一个黑客来强制每个实例解决使用以下代码到不同的位置: var rootDirUserField= typeof(IsolatedStorageFile).GetField(“s_RootDirUser”, BindingFlags.NonPublic | BindingFlags.Static); rootDirUserField.SetValue(null, “”); 虽然这让问题消失了但我不喜欢它。 请帮助弄清楚如何优雅地解决这个问题。 在进一步的研究中,我发现IsolatedStorage甚至不打算用于多个线程,这让我想知道为什么它在处理Packages时是一个选项。 at System.IO.IsolatedStorage.IsolatedStorageFileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, IsolatedStorageFile isf) at MS.Internal.IO.Packaging.PackagingUtilities.SafeIsolatedStorageFileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, ReliableIsolatedStorageFileFolder folder) at MS.Internal.IO.Packaging.PackagingUtilities.CreateUserScopedIsolatedStorageFileStreamWithRandomName(Int32 retryCount, String& fileName) at MS.Internal.IO.Packaging.SparseMemoryStream.EnsureIsolatedStoreStream() at MS.Internal.IO.Packaging.SparseMemoryStream.SwitchModeIfNecessary() at MS.Internal.IO.Packaging.SparseMemoryStream.Write(Byte[] buffer, Int32 offset, […]

在IsolatedStorageSettings中存储对象

我有一个对象我想存储在IsolatedStorageSettings中,我不想在应用程序重启时重用它。 我的问题在于,由于某种原因我编写的代码在重新启动时尝试访问密钥时不记得该对象。 namespace MyNameSpace { public class WindowsPhoneSettings { private const string SelectedSiteKey = “SelectedSite”; private IsolatedStorageSettings isolatedStore = IsolatedStorageSettings.ApplicationSettings; private T RetrieveSetting(string settingKey) { object settingValue; if (isolatedStore.TryGetValue(settingKey, out settingValue)) { return (T)settingValue; } return default(T); } public bool AddOrUpdateValue(string Key, Object value) { bool valueChanged = false; if (isolatedStore.Contains(Key)) { if (isolatedStore[Key] != […]

将PNG图像保存到WP7的隔离存储

这里有相当多的图像到隔离存储问题,但我找不到适合我情况的好答案 – 所以我们走了。 我从网络上获取一个.png图像,并将其保存为BitmapImage -object。 当它完成加载(在BitmapImage.ImageOpened事件上)时,我想将它保存到独立存储。 那么,我怎样才能从这个BitmapImage(或直接来自网络)获取字节或文件流 – 这无关紧要,以便我可以将它写入我的IsolatedStorageFileStream ? 我无法在互联网上找到一篇关于它的文章, BitmapImage.StreamSource适用于WP7(因此BitmapImage.StreamSource不可用).png图像。 任何帮助将不胜感激。

我无法保存到隔离存储?

我正在尝试将模型保存在独立存储中: var settings = IsolatedStorageSettings.ApplicationSettings; CurrentPlaceNowModel model = new CurrentPlaceNowModel(); settings.TryGetValue(“model”, out model); if (model == null) { MessageBox.Show(“NULL”); settings.Add(“model”, new CurrentPlaceNowModel()); settings.Save(); } else MessageBox.Show(“NOT NULL”); 当我启动emu i ofcourse时“NULL”,但是如果我关闭emu上的应用程序并从菜单中再次启动它(为什么我在Visual Studio中再次启动它),为什么还要继续使用它。 第二次我不应该得到“NOT NULL”吗?

如何在隔离存储中保存超链接按钮

我有一个超链接按钮列表,在运行时创建 public void SaveBookmark() { Button objButton = new Button(); objButton.Content = “Delete”; objButton.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; objButton.Foreground = new SolidColorBrush((Colors.Black)); objButton.BorderBrush = new SolidColorBrush((Colors.Black)); HyperlinkButton objhyperlinkbtn = new HyperlinkButton(); objhyperlinkbtn.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; objhyperlinkbtn.FontSize = 34; objhyperlinkbtn.Foreground = new SolidColorBrush((Colors.Black)); objhyperlinkbtn.Tag = Index; stackpanel.Children.Add(objhlbBookMark); stackpanel.Children.Add(objButton); } 我想将它保存在独立存储中。 请帮我把它保存在隔离存储中。 我想让用户选择书签,如果用户保存书签然后超链接按钮保存在页面上以查看书签列表