IsolatedStorageFileStream上不允许操作

时间:2011-08-30 06:42:40

标签: silverlight silverlight-4.0 isolatedstorage

我一直在尝试使用独立存储在c:驱动器上打开文件,我尝试了不同的方法,但它们都给出了相同的错误,这是代码;

IsolatedStorageFile ifs = IsolatedStorageFile.GetUserStoreForApplication();
Stream stream = new IsolatedStorageFileStream("avi.txt", FileMode.Open, FileAccess.Read, ifs);

我甚至尝试过:

1)

Stream stream = new IsolatedStorageFileStream(@"avi.txt", FileMode.Open, FileAccess.Read, ifs);

2)

Stream stream = new IsolatedStorageFileStream(@"files/avi.txt", FileMode.Open, FileAccess.Read, ifs);

3)

Stream stream = new IsolatedStorageFileStream("files/avi.txt", FileMode.Open, FileAccess.Read, ifs);

如何在不使用对话框的情况下打开文件。

提前谢谢

1 个答案:

答案 0 :(得分:1)

我无法解释您所看到的错误,因为我希望看到找不到文件错误。

在我看来,您正在尝试使用独立存储来访问客户端文件系统中的文件。

您需要运行具有提升信任的OOB。然后,您可以使用System.IO.File打开文件,即使这样,您也被限制为当前用户的MyDocuments区域。

除此之外,您需要向用户显示一个对话框。

相关问题