gpt4 book ai didi

c# - Windows Phone 中的 "Operation not permitted on IsolatedStorageFileStream"问题

转载 作者:行者123 更新时间:2023-11-30 17:47:52 25 4
gpt4 key购买 nike

我已将视频文件保存在 IsolatedStorage 中,并使用 Windows Phone 8 中的 Media Element 播放它。这是第一次,它执行得非常好并成功运行,我能够播放视频,

问题是,每当我第二次玩的时候,都会出现这样的错误:

"Operation not permitted on IsolatedStorageFileStream"

查看我的代码:

 string mediafile = "asaqwrereertrtyrzxxcvcvvbvbv+qwwezzxzxz";
byte[] PlayByte = Convert.FromBase64String(mediafile);
MemoryStream stream = new MemoryStream(PlayByte, 0, PlayByte.Length);


IsolatedStorageFileStream isfStream = new IsolatedStorageFileStream(audioName, FileMode.OpenOrCreate,FileAccess.ReadWrite, IsolatedStorageFile.GetUserStoreForApplication());
isfStream.Write(stream.ToArray(), 0, stream.ToArray().Length);
isfStream.Close();
Uri uri = new Uri(isfStream.Name.ToString());
MediaElement1.Source = uri;
MediaElement1.Play();

最佳答案

应该通过处理该流来解决意味着当音频停止播放时通过 isfStream.Dispose(); 处理流所以它不会抛出异常但问题仍然存在您可以尝试给出的解决方案下面:

当您多次同时执行该代码块时,通常会发生这种情况。您最终锁定了文件。因此,您必须确保在构造函数中包含 FileAccessFileShare 模式,如下所示:

using(var isfStream = new IsolatedStorageFileStream(audioName, FileMode.OpenOrCreate,FileAccess.ReadWrite, IsolatedStorageFile.GetUserStoreForApplication())
{
//...
}

关于c# - Windows Phone 中的 "Operation not permitted on IsolatedStorageFileStream"问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24076997/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com