views:

33

answers:

2

Hi,

How can i create a file and write to it using the memory stream? I need to use the memorystream to prevent other threads from trying to access the file.

The data i'm trying to save to a file is html.

How can this be done?

+1  A: 

This tutorial from MSDN should help you solve your problem

npinti
+1  A: 

(Presuming you mean how to copy a file's content to a memory stream)

If you are using framework 4:

     MemoryStream memoryStream = new MemoryStream();
     using (FileStream fileStream = new FileStream(FilePath, FileMode.Open, FileAccess.Read))
     {
       fileStream.CopyTo(memoryStream);
     }
vc 74
The data that is comming in, comes from a webbrouwser control. The html content of a website. That will be passed to a string and from there saved to a file. But before that, i do some string operations removing things that don't need to be saved like Flash en javascript.
Yustme