Sample Code:
// Open the file
FileStream fs = File.Open(@filename, FileMode.Open);
// Get the file length
long fileLen = fs.Length;
// Create Buffer of size fileLen
Byte[] buff = new Byte[fileLen];
// Read the file into the buffer
int readLen = fs.Read(buff, 0, fileLen)
if (readLen != fileLen)
throw new IOException();
// Create the Memory Stream from the Buffer
MemoryStream ms = new MemoryStream(buff, true);
--------------------
| From: "Jeroen Ceuppens" <
[email protected]>
| Subject: MemoryStream
| Date: Thu, 18 Dec 2003 16:09:59 +0100
| Lines: 16
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <
[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| NNTP-Posting-Host: d5778b1e.kabel.telenet.be 213.119.139.30
| Path:
cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.
phx.gbl
| Xref: cpmsftngxa07.phx.gbl
microsoft.public.dotnet.framework.compactframework:41278
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
|
| Hi,
|
| I want to copy the stream:
| Stream st = File.Open(@filename, FileMode.Open);
|
| the file is a bmp
|
| to a memorystream, what is the best way to do this?
|
|
|
| Greetz
|
| JC
|
|
|