1,274 questions
3
votes
2
answers
60
views
Why does closing a memory stream used to create an Image object effect a new Image object?
Question:
Why does a MemoryStream object used for ImageA effect a cloned Image object named ImageB? I know Microsoft says that when you create an Image object from a memory stream you have to leave ...
0
votes
1
answer
33
views
DecodeToAsync does not fill the MemoryStream for a PDF file
I used this code to download the PDF file from attachment. And when I connecting to gmail IMAP it's working great. But when I try to connect another IMAP server DecodeToAsync just can't decode it to ...
0
votes
1
answer
48
views
Why do I get the error "Cannot access a disposed object" when using a stream
I am trying to read an xlsx file using CloseXlm so I created the below ReadFile method. In order to test it, I've created a test method using MSTest and another method that creates an xlsx file and ...
0
votes
0
answers
32
views
Saving a tag to an image file and loading it again all in memory
I can't seem to get the tag I'm adding to an image to stick once I save the image to a memory stream. Any idea how I can get that tag to end up in the imageCache byte array after I try and copy it to ...
1
vote
0
answers
25
views
Post file from memory stream
I want to upload a picture file without saving it to the hard disk (mainly because of performance). My code is as shown below.
Public Shared Function ConvertToByteArray(ByVal value As Bitmap) As Byte()...
-1
votes
2
answers
103
views
What are the alternatives to using a MemoryStream twice here?
I'm trying to write code that stamps a passport with the system users name, date and an image of their signature (which I store as a varbinary in the sql database and byte in the model).
Here is my ...
1
vote
1
answer
62
views
Creating file on remote directory using MemoryStream, WinSCP and PowerShell
I have read on WinSCP's site that you can create a file on the remote FTP server using the method Session.PutFile and using a MemoryStream to create the object on the remote directory.
The syntax ...
1
vote
0
answers
46
views
How to mock returning a memorystream multiple times?
I have this call to an external source that returns a FileResponse object that also contains a Stream object. To Mock it I use a MemoryStream object and that works as long as the test is focused on ...
1
vote
1
answer
47
views
MemoryStream.Write works on Client but not on Server?
I have a very basic understanding about what I am doing. So I was following a tutorial about a chat app on C# and there are 2 classes which are comletely same however; while the code works completely ...
0
votes
2
answers
55
views
When to close memory streams if they are returned in methods and controllers
I have some code that will be generating an excel report and I am planning on using it for some scheduled tasks but always wanted to return it from my API endpoint as well. My code for my controller ...
1
vote
1
answer
71
views
Write and read string from MemoryStream
Please consider this scenario:
I want to read a file and then place its bytes to MemoryStream and then write some strings to it and then immediately read entire MemotyStream. For example I have a text ...
0
votes
1
answer
57
views
Load picture from SQL and set it as a picturebox image in C# [closed]
I am using this code to load an image from SQL and set it as a picturebox image. but the code does not work. I use "image"/"varbinary(Max)" for Logo image in SQL Server.
byte[] ...
0
votes
0
answers
80
views
SaveAs(memoryStream) Takes too long
I have a serious problem with this code:
ajaxAuthenticator.Authenticate();
XLWorkbook template = templateBuilder.BuildTemplate();
using (MemoryStream memoryStream = new MemoryStream())
{
...
0
votes
1
answer
35
views
How to include the file name and the file extension when using MemoryStream in blazor webassembly
Here is my code
getting the file from FileSelectFileInfo
public FileSelectFileInfo selectedFile { get; set; }
then if there is a selected file, i store it in the variable above
private async Task ...
0
votes
0
answers
51
views
How to copy a single IFormFile to multiple memorystream concurrently
I have a IFormFile which I pass as a parameter to two separate asynchronous functions which convert the IFormFile to a memorystream which one uploads to OneDrive via ms graph and one uploads the other ...
1
vote
0
answers
135
views
How to create a ZIP file from byte array using Microsoft.IO.RecyclableMemoryStream?
I need to save a byte array as a compressed ZIP file. As MemoryStream can grow large and cause out-of-memory exceptions on our shared Azure server instances, I'm using Microsoft.IO....
0
votes
0
answers
102
views
Unity AudioClip.PCMReaderCallback is not being called when audioBuffer is written
I'm having some trouble with using PCMReaderCallback. The callback is never called when the audioBuffer is filled. It should be called automatically by Unity. Here is a sample of my code:
private ...
1
vote
0
answers
154
views
Forwarding file stream to client in Blazor WebServer in .NET 8
I'm writing a Blazor WebServer application which, at one point, allows the client to download a file. This file is forwarded from another API, which offers it as an application/octet-stream message, ...
0
votes
0
answers
122
views
How to avoid "Cannot access a disposed object" MemoryStream errors in async lambda functions
I have an issue that I can solve by running my code synchronously and it works great but to reduce wait time for my users I need to run async for this method as I have a few other tasks that need to ...
0
votes
0
answers
51
views
.Net 6 StreamReader.ReadBlockAsync throw System.ObjectDisposedException when reading file
I have a problem when trying to read a file from an FTP server. Thousands of files have been read without problem. This problem only occurs for 1 file. The problem occurs when I use the method ...
0
votes
1
answer
216
views
How to create Javascript WritableStream on memory (like fs.creareWriteStream)
I try to use some JS library with ServiceWorker, without access to Node.JS FileSystem functionality. That original library export result in the same way
Import * as fs from 'fs'
...
JsLib.export(...
1
vote
1
answer
139
views
Configuring Apache Spark's MemoryStream to simulate Kafka stream
I was requested to look into using Apache Spark's MemoryStream to simulate a Kafka stream in a Java Spring Boot service. The documentation / online community is a bit small on this topic so I am ...
0
votes
1
answer
46
views
"Parameter is not valid" exception when using Image.FromStream() - UDP Video live stream
I am trying to live stream the camera from a Raspberry pi to a PC with UDP. I followed the example code provided by the Picamera2 library to send the livestream data with python and am using C# ...
0
votes
0
answers
43
views
WPF How to show a MemoryStream PDF document to a WebBrowser
I cant show a pdf document save it in a database table direcly to a WebBrowser using a MemoryStream.
I have a DataBase with pfd documents saved in a table filed, and I want to show the pdf document ...
1
vote
1
answer
137
views
Pass Memory Stream Image directly into ImageMagick command in PowerShell
I am wanting to take an existing Memory Stream image and pass it into ImageMagick execute command directly without saving the file physically to the machine. The code below gives an example what I ...
0
votes
0
answers
164
views
How to download file into memory with WebView2?
I want to download a file in WebView2 into memory instead of saving it to the disk. However, I can't find a method in WebView2 to allow me to do anything except change the path where the file will be ...
1
vote
1
answer
318
views
Why Memory Stream does not work with FluentEMail.Core.Model.Attachment for sending files?
I was creating an action method for sending emails in asp.net web api using FluentEmail.
I wanted to send multiple attachments with my email.
I first used Memory Stream to copy the file into the ...
0
votes
1
answer
127
views
ClientWebSocket - MemoryStream, message framing and performance
This is more of a theoretical question around possible performance optimizations when using C# ClientWebSocket.
Consider following implementation for receiving socket messages.
private async Task ...
-1
votes
1
answer
487
views
Blazor IBrowserFile OpenReadStream() blocks UI thread
I am trying to create a functionality to enable users to upload large files (upto 5GB).
Technically, unrelated to this issue but I am uploading them to s3 via multipart upload [I've tried both low ...
0
votes
1
answer
55
views
Unable to display the content loaded from MemoryStream in a particular paragraph in Gembox.Document
I have a document that is made up of different paragraphs
<p> paragraph 1<p/>
<p> paragraph 2<p/>
<p> paragraph 3 content is from an uploaded pdf document <p/>
<...
0
votes
1
answer
215
views
Images in CollectionView disappear on scrolling
I am currently working on a CollectionView to display a number of images on .NET MAUI. I am not using any third party library to manage image caching. I am able to start a task that eventually takes ...
1
vote
1
answer
684
views
MemoryStream threw an exception of type 'System.InvalidOperationException'
No matter what, new instances of MemoryStream in C# / .NET 8.0 keep throwing this exception:
CanRead [bool]: true
CanSeek [bool]: true
CanTimeout [bool]: false
CanWrite [bool]: true
Capacity [int]: ...
1
vote
1
answer
232
views
Why can't System.Text.Json serialize MemoryStream?
I have a class with a MemoryStream property. When I attempt to serialize it using System.Text.Json, I'm getting an exception:
An unhandled exception of type 'System.InvalidOperationException'
...
1
vote
1
answer
345
views
How to read images from memory to ImageSource in C++/WinRT (WinUI3)?
[1]
I want to display an image for the Image control in XAML, but this image comes from a bytes array.
What should I do? The image format may be one of JPG, BMP, or PNG.
<Image x:Name="img&...
2
votes
2
answers
536
views
C# Merging multiple memory streams and returning via filestreamresult, showing only last memory stream
I am trying to merge multiple pdf files into one memory stream and return it with FileStreamResult to web application.
My code is like that:
string contentType = "application/pdf";
...
0
votes
1
answer
93
views
Open XML: How to save an existing WordprocessingDocument to MemoryStream?
In my class, I receive a WordprocessingDocument object as a return from another method. I know the document was created in-memory (MemoryStream).
Now, I need to either get the underlying MemoryStream ...
0
votes
0
answers
290
views
Pulling PDF form fields/values in C# using iText7 and memory streams
I am getting a "PDF header not found" error when trying to use iText7 but working purely with loading the pdf via memorystreams rather than a file path for it saved on a server. Is this not ...
0
votes
0
answers
38
views
Does a MailMessage Attached to a Stream Generate a File?
In one method I have the below code:
var newMessage = new MailMessage();
newMessage.Attachments.Add(new Attachment(ToStream("testAttachment"), MediaTypeNames.Text.Plain));
Then I have this ...
-2
votes
1
answer
297
views
Image encrypting with AES c#
I have to encrypt and decrypt Image by AES each algorithm.
I have following code that encrypt Image:
public static byte[] MakeEncryption(Image image, CipherMode mode, byte[] key, byte[] iv)
{
...
0
votes
1
answer
306
views
Large File Upload Results in Corrupted Files
I am currently working on a file upload feature in my application, and I am encountering an issue where the uploaded file appears to be corrupted. The application is designed to handle large file ...
1
vote
0
answers
1k
views
C# MemoryStream and returning a csv file within a controller using CsvHelper [duplicate]
Intended Outcome: From an instance of a specific object (Item) to output the data into a csv file within a API controller.
Approach: To achieve this I have written a class called Item with two ...
0
votes
0
answers
76
views
Closed memorystream. cannot find the error
Please take a look at this:
Controller:
public IHttpActionResult GetExcel(InputSimpleString supplierNo)
{
var stream = handler.GetExcelOld(supplierNo.input, true);
if (stream != null)
{
...
0
votes
1
answer
194
views
Converting System.Drawing.Bitmap to a ImageSource memory stream to insert into a PdfSharpCore PdfDocument under Linux
I'm creating a barcode using DataMatrix.NetCore nuget package. I'm attempting to get that inserted into a PDF using PdfSharpCore. The barcode is generated and a bitmap is created, but the conversion ...
0
votes
1
answer
122
views
Save ZipArchive to Stream
I am working on a project where i update a ZipArchive and upload it back to server but I can only upload it using a stream.
public IActionResult DeleteZippedFile(string path)
{
//read the zip from ...
0
votes
1
answer
70
views
Out of memory exception for converting 40 mil records from csv stream to tab delimited text stream
I am trying to convert csv stream to a tabdelimeted text memory stream it is giving me error of out of memory exception when it is trying to write to the stream, it is getting processed in local ...
0
votes
2
answers
144
views
MemoryStream brings half of data when generating a CSV string
I do have really a simple question, but takes a lot of times for finding out a solution. Still couldn't find and thought to post here.
Below is the code for getting CSV formatted string. But the issue ...
2
votes
1
answer
1k
views
Aspose.Pdf.Document.Save() throws an exception of type 'System.InvalidOperationException' when used with a MemoryStream
We are trying to save a PDF document using the Aspose.Pdf.Document.Save() method. Our code worked when run as .netcore3.1 but we have upgraded to .NET6 and it is now failing. Our Aspose version has ...
0
votes
2
answers
650
views
How to read from a stream you've just written to without calling Flush() in C#
I have some code that uses a 3rd party library, EDIFabric, which writes to a stream, which I need to capture that output and use it to return a string by way of a StreamReader.
// Build out the ...
0
votes
1
answer
3k
views
Convert byteArray to xls file
Core 7 application.
From an API call, I am receiving a xls file through Json and need to read/process the file.
I convert the string to a byteArray[]
byte[] byteArray = Convert.FromBase64String(dta);
...
0
votes
0
answers
161
views
Binary Formatter serialize-deserialize
I have 2 voids to serialize/Deserialize my class data (what is serializable)
But sometimes i get error:
TableDataObject translater: The input stream is not a valid binary format. The starting contents ...