byte[,] bytes=new byte[50,100];
for (int i=0;i<50;i++)
{
for (int j=0;j<100;j++)
bytes[i,j]=i+j;
}
Stream stream;
stream.Write(by tes,0,bytes.Len gth);
I get this error when compiling: Argument '1': cannot convert from
'byte[*,*]' to 'byte[]' 2 1415
Jeroen,
This makes sense, because it only takes a single dimensioned array of
bytes. What you need to do is call Write (or WriteByte), passing in one
byte at a time, or creating a single array of 5000 elements which will hold
the bytes contiguously.
Or, you could use serialization to serialize the byte array and write it
to a stream. This is probably the best option, IMO.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- ni************* *@exisconsultin g.com
"Jeroen Ceuppens" <Je************ *@barco.com> wrote in message
news:eM******** ******@TK2MSFTN GP09.phx.gbl... byte[,] bytes=new byte[50,100];
for (int i=0;i<50;i++)
{
for (int j=0;j<100;j++)
bytes[i,j]=i+j;
}
Stream stream;
stream.Write(by tes,0,bytes.Len gth); I get this error when compiling: Argument '1': cannot convert from 'byte[*,*]' to 'byte[]'
thx
"Nicholas Paldino [.NET/C# MVP]" <ni************ **@exisconsulti ng.com> wrote
in message news:OA******** *****@TK2MSFTNG P11.phx.gbl... Jeroen,
This makes sense, because it only takes a single dimensioned array of bytes. What you need to do is call Write (or WriteByte), passing in one byte at a time, or creating a single array of 5000 elements which will
hold the bytes contiguously.
Or, you could use serialization to serialize the byte array and write
it to a stream. This is probably the best option, IMO.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - ni************* *@exisconsultin g.com
"Jeroen Ceuppens" <Je************ *@barco.com> wrote in message news:eM******** ******@TK2MSFTN GP09.phx.gbl... byte[,] bytes=new byte[50,100];
for (int i=0;i<50;i++)
{
for (int j=0;j<100;j++)
bytes[i,j]=i+j;
}
Stream stream;
stream.Write(by tes,0,bytes.Len gth); I get this error when compiling: Argument '1': cannot convert from 'byte[*,*]' to 'byte[]'
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jason |
last post by:
How can I create a stream object from webservice that returns an image in byte format?
|
by: Yechezkal Gutfreund |
last post by:
I have been using the following code (successfully) to read Xml formated
text packets from a TCP stream. The output from the server stream consists
of a sequence of well formed Xml documents written to the output stream.
We are willing to pay $ to any expert (e.g. MVP) consultant who has to time
to help us track down this problem.
(we will discuss rates if you can prove your expertise, and problem solving
approach).
|
by: andrewcw |
last post by:
OK I am half way there - I can manipulate the stream
without the byte issue like this - but is this the way to
push the new values back into the stream & write out the
stream without resorting to byte conversion ??
FileStream stream = null;
stream = File.Open(fiPath, FileMode.Open,
FileAccess.ReadWrite,FileShare.None);
System.IO.StreamReader Tin = new System.IO.StreamReader
(stream);
|
by: Scott, Killer of all Ninjas |
last post by:
It seems incredulous to me that it is so difficult to write the
contents of a memory stream to a file. I'm certain that I'm missing
something simple.
I am retrieving a memory stream from a DIME attachment:
MyDimeService svc = new MyDimeService();
svc.CreateDimedImage();
if (svc.ResponseSoapContext.Attachments.Count == 1)
{
|
by: Laszlo Szijarto |
last post by:
Can BinaryReader be forced to read a stream, say a TCP/IP stream or memory
stream or even file stream in big endian order or do I have to write
something custom to reverse the byte order? So, for example, I'd like a
Windows client PC (native little endian) to be able to read a network stream
coming in as big endian. I want to be able to read a short for example
without worrying about flipping the bytes.
Thank you,
Laszlo
| |
by: Li Zhang |
last post by:
I have a problem with reading byte from a memory stream. Basically I
want to resize a image and then store them to sql server. Here is part
of the codes. every time I tried to read byte from stream, I only got
all 0 byte, I don't know what is the problem. Please help me to check
my error. Thanks.
httpImageFile = imageFile.PostedFile;
imageSize = httpImageFile.ContentLength;
imageContentType = httpImageFile.ContentType;
imageFileName =...
|
by: ad |
last post by:
I want to uplad a dataset to server by WebService,
But the dataset is to huge (50 fields in 50000 rows)
I want to compress it before upload,
Now my steps are
In Client
1. DataSet1.WriteXml("c:\my.xml")
2. Zip c:\my.xml to my.zip
3. Delete my.xml
4. Reade my.zip into FileSteam
5. Write the FileStream to Byte
|
by: semedao |
last post by:
Hi,
I am using cryptostream on both sides on tcp connection that pass data.
I am also use asyc socket , so , the data that recieved in the callback
method not always have the length of the buffer I sent.
for ex
I want to send 10000 bytes
I can get it in 10 times of 1000 bytes each.
so , I need to know when I complete the receiving , I want to write inside
cryptostream and check the position compare it to the length I already know
I...
|
by: Hardy Wang |
last post by:
Hi all,
I am new to WSE 3.0, and currently reading the document shipped with
installation. From sample provided (see below), I created WSE service side
code, but how can I consume stream returned by web method in my Web Form
application? I already configurated web.config of my web service by running
WSE 3.0 setting tool.
Thanks!
|
by: Iridium |
last post by:
Greetings,
I am trying to get a JPG Frame from a MJPG Stream. A MJPG is basically a stream of JPGs which are splitted by a special boundary string. So I tried to get the stream, split it by the boundary strings and save the JPG binary data into a file.
The problem is, I cant save the data into a proper JPG file which I then open. This is my code:
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |