Global access to MemoryStream
I want to serialize an object(Form) to the MemoryStream and ulteriorly be able to deserialize it. Is it possible to keep (read and write into) a global "memoryStreamContainer" when application is running? ...
I want to serialize an object(Form) to the MemoryStream and ulteriorly be able to deserialize it. Is it possible to keep (read and write into) a global "memoryStreamContainer" when application is running? ...
Hello, I'm trying to find a way of indenting a HTML file, I've been using XMLDocument and just using a XmlTextWriter. However I am unable to format it correctly for HTML documents because it checks the doctype and tries to download it. Is there a "dumb" indenting mechanism that doesnt validate or check the document and does a best eff...
There's a bit of code which writes data to a MemoryStream object directly into it's data buffer by calling GetBuffer(). It also uses and updates the Position and SetLength() properties appropriately. This code works properly 99.9999% of the time. Literally. Only every so many 100,000's of iterations it will barf. The specific problem i...
What is the difference between instantiating a Stream object, such as MemoryStream and calling the memoryStream.Write() method to write to the stream, and instantiating a StreamWriter object with the stream and calling streamWriter.Write()? Consider the following scenario: You have a method that takes a Stream, writes a value, and retu...
Hello, I need to create an ASP.NET 2.0+ web application that allows the user to upload some excel files; the contents from these files should be saved into some SQL database. The problem is with the connection string one should use in ADO.NET. According to this entry (and few others from SO), one has to specify the physical path to the ...
I am testing BinaryFormatter to see how it will work for me and I have a simple question: When using it with the string HELLO, and I convert the MemoryStream to an array, it gives me 29 dimensions, with five of them being the actual data towards the end of the dimensions: BinaryFormatter bf = new BinaryFormatter(); ...
Ive found out that you can serialize a wpf component, in my example a FixedDocument, using the XamlWriter and a MemoryStream: FixedDocument doc = GetDocument(); MemoryStream stream = new MemoryStream(); XamlWriter.Save(doc, stream); And then to get it back: stream.Seek(0, SeekOrigin.Begin); FixedDocument result = (FixedDocument)XamlR...
in VB.NET How can i write a memory stream to browser.My memory stream object has data to build a PDF file.Now i want it to be rendered on browser.How to do that ? Thanks in advance ...
I would like to know whether using a BinaryReader on a MemoryStream created from a byte array (byte[]) would reduce performance significantly. There is binary data I want to read, and I get that data as an array of bytes. I am currently deciding between two approaches to read the data, and have to implement many reading methods accordin...
I'm trying to do a find and replace in an OpenXML word document which I've openened into a MemoryStream. using (WordprocessingDocument _document = WordprocessingDocument.Open(_ms, true)) { var placeHolder = _document.MainDocumentPart.Document .Descendants<DocumentFormat.OpenXml.Wordprocessing.Text>() ...
So I'm using a StreamReader that uses a MemoryStream to write to a StreamWriter and inside of this application but the memory usage increases by 300mb (From one of the larger inputs) and does not deallocate after Im done using it: StreamWriter log = new StreamWriter("tempFile.txt"); log.Write(reader.ReadToEnd()); log.Close(); reader.Di...
Hey all, At the moment I am experiencing a very frustrating problem. I will try to abstract the problem to make it a bit easier. It has to with serializing my custom object to a database in one process and deserializing it in another process. I have two assemlies; AppToDB.dll and AppFromDB.dll. I have a 3rd assembly - MyCustomObject.d...
Hi , I want to show data on pdf format , The source ( base64 format ) is a parameter , not a file , and my code is : byte[] bytes = System.Convert.FromBase64String(source); MemoryStream fs = new MemoryStream(bytes, 0, bytes.Length); fs.Position = 0; fs.Seek(0, SeekOrigin.Begin); fs.Read(bytes, 0, Convert.ToInt32(...
Hi, there a way to determine that I am passing the right byte array to the MemoryStream if I want to create an Image out of byte array. MemoryStream mStream = new MemoryStream(); mStream.Write(byteArray, 0, byteArray.Lenth); Image imgObj = Image.FromStream(mStream); How can I, if possible Correct the byteArray that it is a valid byteA...
I have the following constructor method which opens a MemoryStream from a file path: MemoryStream _ms; public MyClass(string filePath) { byte[] docBytes = File.ReadAllBytes(filePath); _ms = new MemoryStream(); _ms.Write(docBytes, 0, docBytes.Length); } I need to change this to accept a Stream instead of a file path. Whats...
public static string SerializeObject<T>(T obj) { try { string xmlString = null; MemoryStream memoryStream = new MemoryStream(); XmlSerializer xs = new XmlSerializer(typeof(T)); XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, Encod...
Ok, here is the thing. My program saves an image into a SQL Server Database, the column being of image type. When I try to recover it, I get an ArgumentException from the Imagen.FromStream method. The code that inserts the image is something like this: Bitmap img = (Bitmap)pictureBox.Image; MemoryStream m = new MemoryStream(); img.Save...
I have a FileSyncProvider and I've written a custom implementation of the FullEnumerationSimpleSyncProvider. When files are synced from the FullEnumerationSimpleSyncProvider to the FileSyncProvider they are created correctly, but are zero bytes. When synchronising in the other direction (FileSyncProvider as source) everything works as e...
Is there a way, either within the Framework or by using P/Invoke to determine the duration of a wav file that's held in a MemoryStream? I've already had a look at Managed DirectX and another similar question, but everything seems to work with paths, rather than providing any way to pass in a stream. One of the links in the question I'v...
I have a JSON string in a MemoryStream. I am using the following code to get it out as an ASCII string: MemoryStream memstream = new MemoryStream(); /* Write a JSON string to memstream here */ byte[] jsonBytes = new byte[memstream.Length]; memstream.Read(jsonBytes, 0, (int)memstream.Length); string jsonString = Encoding.ASCII.GetStri...