【问题标题】:Save image to windows phone 7 pictures hub将图像保存到 Windows Phone 7 图片中心
【发布时间】:2012-06-08 16:54:44
【问题描述】:

我正在尝试将列表框中的选定图片保存到手机内存中,但我不明白为什么会收到“InvalidOperationException was Unhandled”错误。

        var filePath = "Uploads/" + fileListBox.SelectedItem;
        var fileUriSource = new Uri(filePath, UriKind.Relative);

        using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
        {
            using (IsolatedStorageFileStream fileStream = myIsolatedStorage.OpenFile(filePath.ToString(), FileMode.Open))
            {
                MediaLibrary mediaLibrary = new MediaLibrary();
                Picture pic = mediaLibrary.SavePicture("saved" + filePath.ToString(), fileStream);
                fileStream.Close();
            }
        }

我已经在互联网上搜索,但找不到任何答案。任何帮助都会很棒。

谢谢!

【问题讨论】:

  • 这是否发生在通过 USB 数据线连接到 PC 的手机上?如果是这样断开它。
  • 这是在模拟器里,还是用真机?
  • 我正在使用 wp7 模拟器。模拟器和手机除了性能还有区别吗?我的意思是当您使用隔离存储时,文件流......

标签: windows-phone-7 save image


【解决方案1】:

根据MSDN

无效操作异常

如果在用户调用 SavePicture 时抛出的异常 连接到正在运行的计算机。

这是因为库在连接到 PC 上的 Zune 时被锁定,以避免在同步期间更改文件时出现任何问题。
如果您必须在连接的设备上执行此操作,您可以use the WPConnect tool 而不是 Zune。

【讨论】:

  • 感谢您的帮助!我不知道这个。
猜你喜欢
  • 2013-01-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-10-16
  • 1970-01-01
  • 2013-04-13
相关资源
最近更新 更多