开发者

I Get the error message while write data in file --Cannot access the disposable object .Object name :MS.internal.InternalMemorystream

This was the code:

 public static void SaveFile(Stream stream, string fileName = "")
    开发者_如何学编程{
        using (IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication())
        {
            IsolatedStorageFileStream fs = file.CreateFile(fileName);

            var filesize = stream.Length;
            var getContent = new byte[(int)filesize];
            stream.Read(getContent, 0, (int)filesize);
            fs.Write(getContent, 0, (int)filesize);

            fs.Close();
        }
    }


There isn't anything wrong with the code you've posted. The fault is in the code you are using to call this function. Most likely you are passing a Stream which has been disposed prematurely.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜