memorystream

Downloading contents of a Azure blob as a text string taking too long time

柔情痞子 提交于 2019-12-11 03:01:13
问题 I am developing an application that Upload a .CSV file on Azure blob storage from my local machine using simple HTTP web page (REST methods) Once, the .CSV file is uploaded, I fetch the stream in order to update my database The .CSV file is around 30 MB, it takes 2 minutes to upload to blob, but takes 30 minutes to read the stream . can you please provide inputs to improve the speed? Here is the code snippet being used to read stream from the file: https://azure.microsoft.com/en-in

Add multiple pages to pdf form with iTextSharp

北城余情 提交于 2019-12-11 02:53:29
问题 I am trying to fill out a pdf form and the form could have multiple pages of the same form, so instead of writing each one to disk I want to create one pdf document in memory with all the pages. I have seen plenty of example on adding pages from an existing pdf file with FileStream but nothing really for filling out forums and adding it to MemoryStream . basically I need to fill out the forum with PdfStamper then append that form to a "master" MemoryStream because I dont want to write it to

How to create Source for WPF Media Element from byte array using c#?

∥☆過路亽.° 提交于 2019-12-11 02:36:44
问题 I have converted a video to bytes array and stored it in MsSql Database. Now I fetch it from database and I get the byte array. I want to set this byte array as Source of media element and then show this video in WPF application. Please suggest a way where I can convert byte array or memory stream to Media Elements Source? I will not have permission to write on users machine, so writing a file onto user machine and then setting the source will not work for me. 回答1: That's not directly

argumentnullexception bitmap save to memorystream

只愿长相守 提交于 2019-12-10 20:39:30
问题 I'm trying to save my Bitmap to MemoryStream - what wrong in this code? Why it gets me argumentnullexception ?? private void insertBarCodesToPDF(Bitmap barcode) { ....... MemoryStream ms = new MemoryStream(); barcode.Save(ms, System.Drawing.Imaging.ImageFormat.MemoryBmp); //<---- byte [] qwe = ms.ToArray(); ....... } UPD: StackTrace System.Drawing.Image.Save(Stream stream, ImageCodecInfo encoder, EncoderParameters encoderParams) in WordTest.FormTestWord.insertBarCodesToPDF(Bitmap barcode) 回答1

Will a large System.IO.MemoryStream result in my application's memory usage increasing dramatically?

做~自己de王妃 提交于 2019-12-10 19:18:20
问题 I am building a library that allows a user to download files from a URL. One of the options I am considering is letting the user specify the expected MD5 checksum for the file; the library's GetFile(string url) function ensures that the checksum for the downloaded stream matches the one specified by the user. Being aware that the NetworkStream returned by HttpWebResponse.GetResponseStream() is not seekable, I found a way to duplicate the Stream thanks to the answers to this question: How can

Get length of Streamreader

独自空忆成欢 提交于 2019-12-10 14:28:17
问题 How can I get the length of a StreamReader , as I know nothing will be written to it anymore. I thought that maybe I could pass all the data to a MemoryStream , which has a method called Length , but I got stuck on how to append a byte[] to a MemoryStream . private void Cmd(string command, string parameter, object stream) { StreamWriter writer = (StreamWriter)stream; StreamWriter input; StreamReader output; Process process = new Process(); try { process.StartInfo.UseShellExecute = false;

Memorystream.Read() always returns 0 bytesRead with empty byte[]

隐身守侯 提交于 2019-12-10 14:11:04
问题 I currently have a memorystream with length of about 30000 ( Named memStream here ) I wished to read this memorystream in chunks using the following code (I picked up on the net and modified somewhat): byte[] chunk = new byte[4096]; bool hasNext = true; while(hasNext) { int index = 0; while (index < chunk.Length) { int bytesRead = memStream.Read(chunk, index, chunk.Length - index); if (bytesRead == 0) { break; } index += bytesRead; //Do something with this chunk } if (index != 0) // Our

How to open a file from Memory Stream

浪尽此生 提交于 2019-12-10 13:53:53
问题 Is it possible to open a file directly from a MemoryStream opposed to writing to disk and doing Process.Start() ? Specifically a pdf file? If not, I guess I need to write the MemoryStream to disk (which is kind of annoying). Could someone then point me to a resource about how to write a MemoryStream to Disk? 回答1: It depends on the client :) if the client will accept input from stdin you could push the dta to the client. Another possibility might be to write a named-pipes server or a socket

Use MemoryStream and ZipArchive to return zip file to client in asp.net web api

大兔子大兔子 提交于 2019-12-10 13:38:09
问题 I am trying to return zip file from asp.net web api to client using The following Code: private byte[] CreateZip(string data) { using (var ms = new MemoryStream()) { using (var ar = new ZipArchive(ms, ZipArchiveMode.Create, true)) { var file = archive.CreateEntry("file.html"); using (var entryStream = file.Open()) using (var sw = new StreamWriter(entryStream)) { sw .Write(value); } } return memoryStream.ToArray(); } } public HttpResponseMessage Post([FromBody] string data) {

Call to MemoryStream.GetBuffer() succeeds even after MemoryStream.Close(); Why?

跟風遠走 提交于 2019-12-10 13:18:13
问题 I have found the following construct in some open-source code: var mstream = new MemoryStream(); // ... write some data to mstream mstream.Close(); byte[] b = mstream.GetBuffer(); I thought this code would have "unexpected" behavior and maybe throw an exception, since the call to Close should effectively be a call to Dispose according to the MSDN documentation. However, as far as I have been able to tell from experimenting, the call to GetBuffer() always succeeds and returns a valid result,