memorystream

How to bind a MemoryStream to asp:image control?

Is there a way to bind a MemoryStream to asp:image control? ...

How do you get a string from a MemoryStream?

If I am given a MemoryStream that I know has been populated with a String, how do I get a String back out? ...

Is a memory leak created if a MemoryStream in .NET is not closed?

I have the following code: MemoryStream foo(){ MemoryStream ms = new MemoryStream(); // write stuff to ms return ms; } void bar(){ MemoryStream ms2 = foo(); // do stuff with ms2 return; } Is there any chance that the MemoryStream that I've allocated will somehow fail to be disposed of later? I've got a peer...

MemoryStream.Read doesn't copy bytes to buffer - c#

I don't really get it and it's driving me nuts. i've these 4 lines: Image img = Image.FromFile("F:\\Pulpit\\soa.bmp"); MemoryStream imageStream = new MemoryStream(); img.Save(imageStream, ImageFormat.Bmp); byte[] contentBuffer = new byte[imageStream.Length]; imageStream.Read(contentBuffer, 0, contentBuffer.Length); when debugging i ca...

Can an App.Config be loaded from a string or memory stream?

I know that I can load an app.config file from a different location using the following line of code: AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE", ConfigFile); where ConfigFile is a full path location. What I'd like to do though is be able to load a file that has been encrypted for the app.config. Ideally, I'd like to be able to...

Using MemoryStream to write out to XML

I have noticed two different approaches to writing out data to an XML file (error handling omitted for brevity). The first method has you build the XML document and then simply save the XML to a file: using (XmlWriter writer = XmlWriter.Create(fileName)) { writer.WriteStartDocument(true); writer.WriteStartElement("parentelement...

Use a MemoryStream with a function that expects a Filestream

I have some functions here that for example are defined as private int WriteLogikParameterTyp(FileStream filestream) which i can not change. I want them to write into a MemoryStream Object. Is this possible? ...

ASP.NET C# upload MemoryStream content via FTPwebRequest issue

This should be pretty straight forward, and uploading works. BUT when I open the uploaded file on the FTP server it shows binary data which is just some weird characters that look like this [][][][], and its the right file size. how do I add attributes or headers that that will say that this file is an XML? public bool ProcessBatc...

Convert MemoryStream to FileStream creates hundreds of identical files?

I am accessing a httpwebrequest that returns a pdf file as the response. I am reading that response into a memory stream, and later on converting to a file. The problem is, is that hundreds of files are being created. Not sure why, I've tried many ways, and all do the same... This is the first method which returns the memorystream. ...

Does my code properly clean up its List<MemoryStream>?

I've got a third-party component that does PDF file manipulation. Whenever I need to perform operations I retrieve the PDF documents from a document store (database, SharePoint, filesystem, etc.). To make things a little consistent I pass the PDF documents around as a byte[]. This 3rd party component expects a MemoryStream[] (MemorySt...

Image.FromStream() method returns Invalid Argument exception

Hello, I am capturing images from a smart camera imager and receiving the byte array from the camera through socket programming (.NET application is the client, camera is the server). The problem is that i get System.InvalidArgument exception at runtime. private Image byteArrayToImage(byte[] byteArray) { if(byteArray != null) { ...

Delphi: play memorystream in wmp activex

hi..I'm new to this site and I hope someone can help me with my problem. I am using a Delphi language. And I would want to play a memorystream to windowsmediaplayer ActiveX. Is this possible? If it is, can someone give me a hint or something.. sample code maybe. Thanks. ...

refactoring question

Given a method public static string[] Foo(System.IO.Stream stream) { XmlTextWriter xmlWriter = new XmlTextWriter(stream, System.Text.Encoding.ASCII); xmlWriter.WriteStartDocument(); xmlWriter.WriteStartElement("Element"); xmlWriter.WriteEndElement(); xmlWriter.WriteEndDocument(); ...

Creating memory stream from ResponseStream Out of Memory Exception

I am making a call to a httprequest which returns a pdf file in the responsestream. This works well for smaller pdf's, but not the file is up around 25-30MB, it is returning an out of memory exception. MemoryStream memStream = new MemoryStream(); byte[] buffer = new byte[2048]; int bytesRead = 0; do ...

Converting TMemoryStream to String in Delphi 2009

We had the following code previous to Delphi 2009: function MemoryStreamToString(M: TMemoryStream): String; var NewCapacity: Longint; begin if (M.Size = 0) or (M.Memory = nil) then Result:= '' else begin if TMemoryStreamProtected(M).Capacity = M.Size then begin NewCapacity:= M.Size+1; TMemoryStreamProtec...

c# creating file using memorystream instead of textwriter

I have an application that is currently creating a text file to import into an accounting application. It is using the following code to create the file and write lines to it: TextWriter tw = new StreamWriter(ExtractFileName); tw.WriteLine("ref\tACCOUNT\tbatch\tDEBIT\tCREDIT\tDesc"); I now need to create multiple extract fil...

VB -- MemoryStream data not released from memory

Is there something that needs to be done with the following code to release the memory it uses? Dim objImage As MemoryStream Dim objwebClient As WebClient Dim sURL As String = Trim(m_StationInterface.PicLocation) objwebClient = New WebClient objImage = New MemoryStream(objwebClient.DownloadData(sURL)) m_imgLiftingEye.Image ...

MemoryStream vs an array of bytes.

Hi; While using a MemoryStream, I find myself often copying (hence duplicating) data to a temporary array of bytes. I think it's a little bit of a waste of ressource, because MemoryStream dosen't let you directly access the underlying byte array. In this situation, what's the real advantage of a MemoryStream? I have read somewhere tha...

How can I pass MemoryStream data to unmanaged C++ DLL using P/Invoke

I need your help with the following scenario: I am reading some data from hardware into a MemoryStream (C#) and I need to pass this data in memory to a dll implemented in unmanaged C++ (using pointer ??). The data read (into stream) is very large (megabytes). I understand that I can P/Invoke this dll but what I am not sure is how to pas...

Do I need to do StreamWriter.flush() ?

suppose this code (C#): using (MemoryStream stream = new MemoryStream()) { StreamWriter normalWriter = new StreamWriter(stream); BinaryWriter binaryWriter = new BinaryWriter(stream); foreach(...) { binaryWriter.Write(number); normalWriter.WriteLine(name); //<~~ easier to reader afterward. } retu...