创建IsolatedStorageFileStream时发生异常异常
本帖最后由 kiygaven 于 2013-07-07 11:53:33 编辑 我使用Socket从pc端向wp发送文件
在wp端创建IsolatedStorageFileStream对象时发生错误
异常信息如下
[IsolatedStorage_Operation_ISFS]
Arguments:
Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version=4.0.50829.0&File=mscorlib.dll&Key=IsolatedStorage_Operation_ISFS
发生异常的位置是一个自定义事件,红色语句
private void ssReceiver_ReceiveFileCompleted(object sender, SocketOperatorEventArgs e)
{
using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
{
...
using (IsolatedStorageFileStream isfs =isf.CreateFile(Path.Combine("Folder", ssReceiver.SocketFile.FileName)))
{
...
}
}
}
事件的调用是在SocketAsyncEventArgs的Completed事件中
该自定义事件如下
public delegate void ReceiveFileCompletedEventHandler(object sender, SocketOperatorEventArgs e);
public event ReceiveFileCompletedEventHandler ReceiveFileCompleted;
protected virtual void OnReceiveFileCompleted(SocketOperatorEventArgs e)
{
if (this.ReceiveFileCompleted != null)
this.ReceiveFileCompleted(this, e);
}
void ReceivesCompleted(object sender, SocketAsyncEventArgs e)
{
...
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
this.ReceiveFileCompleted(this, new SocketOperatorEventArgs() { ... });
});
...
}
请问这个异常是由于线程的问题吗,该如何解决。 Windows?Phone
[解决办法]
using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
{
//...
isf.CreateDirectory("Folder");
using (IsolatedStorageFileStream isfs = isf.CreateFile(Path.Combine("Folder", ssReceiver.SocketFile.FileName)))
{
//...
}
}