memorystream

Reading from the Pipeline Stream in PowerShell

前提是你 提交于 2020-01-25 23:46:13
问题 Background I'm hoping to write code which uses Microsoft.VisualBasic.FileIO.TextFieldParser to parse some csv data. The system I'm generating this data for doesn't understand quotes; so I can't escape the delimiter; but rather have to replace it. I've found a solution using the above text parser, but I've only seen people use it with input from files. Rather than writing my data to file only to import it again, I'd rather keep things in memory / make use of this class's constructor which

How to stream an mp3 file from a URL without using much RAM?

拜拜、爱过 提交于 2020-01-25 21:51:13
问题 I have a method to stream mp3 from url sources. In this method, the file begins downloading and at the same time the downloaded bytes are stored in a MemoryStream. But I realized that this method is not good. Because the RAM usage is approximately 50 mb when the mp3 file is being played. So I want to make it without storing in MemoryStream. I tried storing the downloaded bytes in a temporary file, but it didn't worked. How to fix it to work with FileStream? It works good using MemoryStream:

Can I convert a bitmap to a jpeg when saving the bitmap to a memory stream?

拟墨画扇 提交于 2020-01-24 21:27:05
问题 I'm attempting to save a bitmap file as a jpeg into Azure without saving it locally in the process, so I am first saving the bitmap as a jpeg in a MemoryStream. But when I execute the following code, the file uploads but it did not convert the bitmap correctly. If I view the file, the viewer displays 'Invalid Image.' I read somewhere that bitmaps cannot be converted to jpegs in memory. Could that be what is happening here? // Retrieve reference to a blob var blobContainer = GetBlobContainer

Difference between Stream.CopyTo and MemoryStream.WriteTo

爷,独闯天下 提交于 2020-01-23 04:15:11
问题 I have a HttpHandler returning an image through Response.OutputStream . I have the following code: _imageProvider.GetImage().CopyTo(context.Response.OutputStream); GetImage() method returns a Stream which is actually a MemoryStream instance and it is returning 0 bytes to the browser. If i change GetImage() method signature to return a MemoryStream and use the following line of code: _imageProvider.GetImage().WriteTo(context.Response.OutputStream); It works and the browser gets an image. So

C# return memory stream from OpenXML resulting to a corrupted word file

和自甴很熟 提交于 2020-01-22 14:38:12
问题 I have a problem with a MemoryStream from OpenXML. I succeed with opening a Word file, changing it and downloading it through the HttpResponse if I do all the steps in a single method. But if I try to do it in two different classes (or methods) by returning the MemoryStream, I get a corrupted word file. I thought about a flushing or buffer problem but I don't find a solution. Here is the working code : public void FillTemplateOpenXmlWord(HttpResponse response) { string filePath = @"c:

No imaging component suitable to complete this operation was found.wpf c# [duplicate]

南楼画角 提交于 2020-01-16 07:40:09
问题 This question already has an answer here : No imaging component suitable to complete the operation was found WPF vb.net (1 answer) Closed 2 years ago . I'm trying to load image from my .mdb database in WPF. I'm using this code : public void loadimg() { con.Open(); OleDbCommand cmd = new OleDbCommand("Select * from recents", con); DataTable table = new DataTable; OleDbDataAdapter adap = new OleDbDataAdapter(cmd); adap.Fill(table); if (table.Rows.Count <= 0) { MsgBox("nooo"); } else {

A generic error occurred in GDI+ when resizing image in MemoryStream

帅比萌擦擦* 提交于 2020-01-16 03:08:13
问题 I am using ImageProcessor to process images in my website. I have this resize function : public Image ResizePhoto6version(Image img, int width, int height) { using (var ms = new MemoryStream()) { using (var imgf = new ImageFactory(false)) { imgf.Load(img) .Resize(new ResizeLayer(new Size(width, height), ResizeMode.Max)) .Save(ms); return Bitmap.FromStream(ms); } } } In the webservice, I run this code : MemoryStream ytSmallStream = new MemoryStream(); MemoryStream ytMediumStream = new

How can I modify an MSI in memory?

时光怂恿深爱的人放手 提交于 2020-01-14 13:05:52
问题 I'd like to read an MSI file into a MemoryStream (or something similar), and modify it. What's the easiest way to do this, without corrupting the MSI? All I need to be able to do is modify the value of one of the properties in the MSI. I'd prefer something in .Net, but I'm open to other platforms. Update: Here's my working code, using the Windows platform SDK, a COM reference to Microsoft Windows Installer Object Library and namespace WindowsInstaller: Installer installer = Activator

How can I modify an MSI in memory?

…衆ロ難τιáo~ 提交于 2020-01-14 13:05:02
问题 I'd like to read an MSI file into a MemoryStream (or something similar), and modify it. What's the easiest way to do this, without corrupting the MSI? All I need to be able to do is modify the value of one of the properties in the MSI. I'd prefer something in .Net, but I'm open to other platforms. Update: Here's my working code, using the Windows platform SDK, a COM reference to Microsoft Windows Installer Object Library and namespace WindowsInstaller: Installer installer = Activator

Compressed content in a byte array to uncompressed in a string

我怕爱的太早我们不能终老 提交于 2020-01-14 03:08:27
问题 How can we create a simple function to take the compressed content from an array of byte (compressed with Deflate method, ANSI encoded) and express it in a string? I go with this one : public string UnzipString3(byte[] byteArrayCompressedContent) { int compressedSize = byteArrayCompressedContent.Length; try { using (MemoryStream inputMemoryStream = new MemoryStream(byteArrayCompressedContent)) { //I need to consume the first 2 bytes to be able read the stream //If I consume 0 or 4, I can't