Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

silverlight

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();
        }
    }
like image 286
kunal rai Avatar asked Feb 06 '26 16:02

kunal rai


1 Answers

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.

like image 121
AnthonyWJones Avatar answered Feb 08 '26 06:02

AnthonyWJones



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!