byte

A first chance exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.dll

核能气质少年 提交于 2019-12-10 17:37:20
问题 Im new to c# client and server application, im working on a file upload client and server application. i can successfully upload my file name and file data to the server from the client application. but when i try to implement a new textbox that allow the file upload client to enter his/her name and send the information together with the file name and file data when he/her click the send button. client application. /* file name and file length */ byte[] fName = Encoding.UTF8.GetBytes(fileName

byte[] to ArrayList?

一世执手 提交于 2019-12-10 17:10:20
问题 Could somebody tell me how can I convert byte[] to ArrayList by using C# under Windows Mobile? Later edit: this would go like having an ArrayList containing instances of a custom type. This list goes to a database (into a blob) as a byte array (the conversion is done by the database API); What I want is to revert the byte[] to ArrayList; .NET CF does not provide the BinaryFormatter; 回答1: All arrays inherit off ICollection, so you can just use ArrayList list = new ArrayList(bytearray);

Java boolean[] to byte[] and back

◇◆丶佛笑我妖孽 提交于 2019-12-10 16:58:27
问题 I am sending byte[] arrays over a socket connection in Java. I have a pretty long boolean[] array, where array.length % 8 == 0 . I'd like to convert this boolean[] array into a byte[] array with 8 times as few elements, so that I can then send the byte[] over the socket connection. The boolean[] array looks like this: 01011010 10101010 01100011 11001010 etc. The byte[] in this case should look like this: 0x5A 0xAA 0x63 0xCA . I have found some code on another question on how to convert a

Python 3 - on converting from ints to 'bytes' and then concatenating them (for serial transmission)

自作多情 提交于 2019-12-10 16:45:31
问题 After much fruitless searching... I am having a very specific issue understanding the way 'bytes' and hexadecimal content is handled in Python 3.2. I KNOW I'm misunderstanding, but can't seem to find the correct path. My ultimate goal is to use the python serial module to transmit a sequence of bytes. Some bytes are static and won't change. Others are supposed to vary from 0-255 in value. These all need to be smushed together and transmitted at once. (These are instructions to a programmable

How to use ICSharpCode.ZipLib with stream?

早过忘川 提交于 2019-12-10 16:27:07
问题 I'm very sorry for the conservative title and my question itself,but I'm lost. The samples provided with ICsharpCode.ZipLib doesn't include what I'm searching for. I want to decompress a byte[] by putting it in InflaterInputStream(ICSharpCode.SharpZipLib.Zip.Compression.Streams.InflaterInputStream) I found a decompress function ,but it doesn't work. public static byte[] Decompress(byte[] Bytes) { ICSharpCode.SharpZipLib.Zip.Compression.Streams.InflaterInputStream stream = new ICSharpCode

Can we write a function in Haskell to measure the number of bytes that a string of n characters occupies?

血红的双手。 提交于 2019-12-10 16:07:09
问题 Suppose I have the string "abc" and I want to calculate the number of bytes it occupies in memory. I could do: import Data.Bits finiteBitSize ("abc" :: [Char]) but that breaks because [Char] is not a type supported by the function. (Also it is bits not bytes, but the point was to paint a picture of what I'm looking for). My question is: Can we write a function in Haskell to measure the number of bytes that a string of n characters occupies? 回答1: There's a Haskell package called ghc-datasize

Difference between unsigned char and char pointers

不羁的心 提交于 2019-12-10 16:07:08
问题 I'm a bit confused with differences between unsigned char (which is also BYTE in WinAPI) and char pointers. Currently I'm working with some ATL-based legacy code and I see a lot of expressions like the following: CAtlArray<BYTE> rawContent; CALL_THE_FUNCTION_WHICH_FILLS_RAW_CONTENT(rawContent); return ArrayToUnicodeString(rawContent); // or return ArrayToAnsiString(rawContent); Now, the implementations of ArrayToXXString look the following way: CStringA ArrayToAnsiString(const CAtlArray<BYTE>

Convert Byte Array to Integer In VB.Net

♀尐吖头ヾ 提交于 2019-12-10 15:36:25
问题 I'm wonder what the best way to convert a byte array (length 4) to an integer is in vb.net? I'm aware of BitConverter, but it seems like quite a waste to do a function call to do something that should be able to be done by copying 4 bytes of memory. Along the same lines, what about converting a single/double from it's binary representation to an single/double variable. 回答1: "Copying bytes of memory" is something that .NET isn't particularly suited for (and VB.NET even less so). So, unless

Converting 3 bytes into signed integer in C#

自古美人都是妖i 提交于 2019-12-10 14:48:00
问题 I'm trying to convert 3 bytes to signed integer (Big-endian) in C#. I've tried to use BitConverter.ToInt32 method, but my problem is what value should have the lats byte. Can anybody suggest me how can I do it in different way? I also need to convert 5 (or 6 or 7) bytes to signed long, is there any general rule how to do it? Thanks in advance for any help. 回答1: As a last resort you could always shift+add yourself: byte b1, b2, b3; int r = b1 << 16 | b2 << 8 | b3; Just swap b1/b2/b3 until you

How to write byte by byte to socket in PHP?

蹲街弑〆低调 提交于 2019-12-10 13:54:45
问题 How to write byte by byte to socket in PHP? For example how can I do something like: socket_write($socket,$msg.14.56.255.11.7.89.152,strlen($msg)+7); The pseudo code concatenated digits are actually bytes in dec. Hope you understand me. 回答1: You can use the pack function to pack the data into any datatype you wish. Then send it with any of the socket functions. $strLen = strlen($msg); $packet = pack("a{$strLen}C7", $msg, 14, 56, 255, 11, 7, 89, 152); $pckLen = strlen($packet); socket_write(