WP8 将 SharedStorge 文件直接复制到 IndependentStorage [英] WP8 copy SharedStorge file directly into IsolatedStorage

查看:31
本文介绍了WP8 将 SharedStorge 文件直接复制到 IndependentStorage的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个 Windows Phone 8 应用程序,但是当我尝试访问本地"文件夹中的文件时,我遇到了很多文件访问权限异常的问题,阻碍了我的应用程序的批准(这只发生在应用程序被由 WP 商店签名,而不是从 Visual Studio 部署时).为了解决这个问题,我将所有文件操作移到了isolatedStorage,这似乎解决了问题.

I am developing a Windows Phone 8 application but am having a lot of issues with file access permission exceptions hindering the approval of my application when ever I try accessing files in the "local" folder (this only happens after the application has been signed by the WP store, not when deployed from Visual Studio). To solve this I have moved all file operations to IsolatedStorage and this seems to have fixed the problems.

不过我只剩下一个问题了.我的应用程序需要使用文件扩展名系统来打开外部文件,这似乎涉及首先将文件复制到本地文件夹,然后我可以手动将其复制到isolatedStorage.我实现这个没有问题,但是一旦系统尝试将外部文件复制到本地文件夹中,似乎也会发生文件访问权限异常.

I only have one problem left though. My application needs to make use of the file extension system to open external files and this seems to involve the file first being copied to the local folder where after I can then manually copy it into IsolatedStorage. I have no problem in implementing this but it seems that a file access permission exception also occurs once the system tries to copy the external file into the local folder.

我认为可以解决此问题的唯一方法是,我是否可以指示系统直接复制到 IndependentStorage 中,但我无法弄清楚如何执行此操作,或者是否可能.似乎 SharedStorageAccessManager 只能复制到 StorageFolder 实例中,但我不知道如何创建一个指向隔离存储的实例,有什么想法吗?

The only way I think this can be solved is if I can direct the system to directly copy into IsolatedStorage but I cannot figure how to do this or if it is even possible. It seems as if though the SharedStorageAccessManager can only copy into a StorageFolder instance but I have no idea how to create one that is directed into IsolatedStorage, any ideas?

附注.你认为微软系统可能会用一些不称职的证书签署我的应用程序还是什么,因为当我从 Visual Studio 部署应用程序时没有任何问题提示,只有在微软测试它或我从商店安装它时才会发生使用 Beta 提交方式.

PS. Do you think that the Microsoft system might be signing my application with some incompetent certificate or something because there is not a hint of trouble when I deploy the application from Visual Studio, it only happens when Microsoft tests it or when I install it from the store using the Beta submission method.

以下是在尝试从电子邮件中打开文件时在消息框中显示的捕获异常的屏幕截图:

Below is a screenshot of the catched exception being displayed in a messagebox upon trying to open a file from an email:

为了更清楚,我不需要帮助来弄清楚使用深层链接 uri 将外部文件复制到我的应用程序目录的正常做法.我需要帮助将其直接复制到隔离存储或解决文件访问异常.

Just to make it even clearer, I do NOT need assistance in figuring out the normal practice of using a deep link uri to copy an external file into my application directory. I need help in either copying it directly into isolatedstorage or resolving the file access exception.

推荐答案

好的,我想通了.安装"目录实际上是限制访问,但出于某种原因,Visual Studio 签名过程使应用程序具有足够的权限来访问此文件夹.确定相对目录的正确过程不是使用Directory.GetCurrentDirectory()",而是使用ApplicationData.Current.LocalFolder".希望这会有所帮助!

Ok I figured it out. The "install" directory is actually restricted access but for some reason the Visual Studio signing process leaves the app with enough permissions to access this folder. The correct procedure of determining a relative directory is not to use "Directory.GetCurrentDirectory()" but rather to use "ApplicationData.Current.LocalFolder". Hope this helps!

这篇关于WP8 将 SharedStorge 文件直接复制到 IndependentStorage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆