Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/silverlight/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在文件中写入数据时收到错误消息--无法访问一次性对象。对象名称:MS.internal.InternalMemorystream_C#_Silverlight - Fatal编程技术网

C# 在文件中写入数据时收到错误消息--无法访问一次性对象。对象名称:MS.internal.InternalMemorystream

C# 在文件中写入数据时收到错误消息--无法访问一次性对象。对象名称:MS.internal.InternalMemorystream,c#,silverlight,C#,Silverlight,这就是代码: public static void SaveFile(Stream stream, string fileName = "") { using (IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication()) { IsolatedStorageFileStream fs = file.CreateFile(fileName);

这就是代码:

 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();
        }
    }

你发布的代码没有任何问题。错误在您用来调用此函数的代码中。很可能您正在传递一个已提前释放的
流。

您需要修复您的问题,以便我们回答。您确定错误消息不是:“无法访问已释放的对象”吗?