Copy Stream object into a MemoryStream object

Posted on 2011-11-01
Last Modified: 2012-05-12
Hi there

Hope you can help me out?

I have a Stream object and I need to but the whole stream object into a memorystream object, do you guys know how to do this?

I have this

stream = new System.IO.FileStream(fn, System.IO.FileMode.Open, System.IO.FileAccess.Read);

I need to put the whole content into a MemoryStream

Hope this helps?

Question by:mousemat24
    1 Comment
    LVL 5

    Accepted Solution

    You can use
    Stream.Write(Byte[] array,Start,Lenght)
    to write on Byte array
    and then create object
    MemoryStream memStream=new MemoryStream(array)

    where array is Byte[] array.



    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now