bytearray

AS3 FTP Programming and the Socket and ByteArray Classes

Sorry for the subject line sounding like an even nerdier Harry Potter title. I'm trying to use AS3's Socket class to write a simple FTP program to export as an AIR app in Flex Builder 3. I'm using an FTP server on my local network to test the program. I can successfully connect to the server (the easy part) but I can't send any comman...

Using C#, what is the most efficient method of converting a string containing binary data to an array of bytes

While there are 100 ways to solve the conversion problem, I am focusing on performance. Give that the string only contains binary data, what is the fastest method, in terms of performance, of converting that data to a byte[] (not char[]) under C#? Clarification: This is not ASCII data, rather binary data that happens to be in a string...

Java: Reading an ASCII file with FileChannel and ByteArrays.

I have the following code: String inputFile = "somefile.txt"; FileInputStream in = new FileInputStream(inputFile); FileChannel ch = in.getChannel(); ByteBuffer buf = ByteBuffer.allocateDirect(BUFSIZE); // BUFSIZE = 256 /* read the file into a buffer, 256 bytes at a time */ int rd; while ( (rd = ch...

Unmanaged C++ encrypted string into C# byte[]

I have an unmanaged C dll I call from a C# class library that encrypts a string value into an encrypted string that contains non-ascii characters. I need to take the data and write its binary values to a file but C# treats text as strings rather than a byte[]. The encrypted value commonly contains special characters (\r, \O, etc). Whe...

convert string to byte[] in java

We try to convert from string to Byte[] using the following Java code: String source = "0123456789"; byte[] byteArray = source.getBytes("UTF-16"); We get a byte array of length 22 bytes, we are not sure where this padding comes from? how do i get an array of length 20? ...

Removing trailing nulls from byte array in C#

Ok, I am reading in dat files into a byte array. For some reason, the people who generate these files put about a half meg's worth of useless null bytes at the end of the file. Anybody know a quick way to trim these off the end? First thought was to start at the end of the array and iterate backwards until I found something other than...

How do you convert a string to a byte array in .Net

I have a string that I need to convert to the equivalent array of bytes in .NET. This ought to be easy but I am having a brain cramp. ...

Convert a Picture Box image to a Byte Array in VB6

I have a VB6 picture box that gets an image from a video capture device. I'm trying to figure out how to then convert the picture box to a byte array. ...

How do you read a byte array from a DataRow in C#?

Howdy, I have a DataSet with a DataTable that fills a single row through a TableAdapter. The TableAdapter is correctly filling a DataRow in the DataTable. I am able to pull data from the DataRow with code like this: dataFileID = (int)this.dataFileDataRow["DataFileID"]; dataFileName = (string)this.dataFileDataRow["DataFileName"];...

Storing images with LINQ to SQL: Converting byte array or stream to Binary

I am working with LINQ to SQL and my image fields are treated as Binary. It's no big issue to convert the Binary type to byte[] (you can just use the ToArray() method of the Binary object) when I need to render the images, but can someone tell me how to turn either a byte[] or Stream object into the Binary object so I can save it back t...

How do you convert Byte Array to Hexadecimal String, and vice versa, in C#?

This is probably a common question over the Internet, but I couldn't find an answer that neatly explains how you can convert a byte array to a hexadecimal string, and vice versa. Any takers? ...

Using java to encrypt integers

Hi all, I'm trying to encrypt some integers in java using java.security and javax.crypto. The problem seems to be that the Cipher class only encrypts byte arrays. I can't directly convert an integer to a byte string (or can I?). What is the best way to do this? Should I convert the integer to a string and the string to byte[]? Th...

Retrieving a byte array stored in a INT field in the database

Hi, how do I retrieve the byte array stored in an integer column in my database? Do I first case it as int, then as byte[] ? byte[] permissions = (byte) Convert.ToInt(dr["myField"]); ? ...

convert bitmap to byte array

How can I convert a bitmap to a byte array in c++ WITHOUT the .net framework? ...

How to create byte array from HttpPostedFile

Hi I'm using an image component that has a FromBinary method. Wondering how do i convert my input stream into a byte array HttpPostedFile file = context.Request.Files[0]; byte[] buffer = new byte[file.ContentLength]; file.InputStream.Read(buffer, 0, file.ContentLength); ImageElement image = Image...

IOException reading a large file from a UNC path into a byte array using .NET

I am using the following code to attempt to read a large file (280Mb) into a byte array from a UNC path public void ReadWholeArray(string fileName, byte[] data) { int offset = 0; int remaining = data.Length; log.Debug("ReadWholeArray"); FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read); ...

Working with byte arrays in C#

I have a byte array that represents a complete TCP/IP packet. For clarification, the byte array is ordered like this: (IP Header - 20 bytes)(TCP Header - 20 bytes)(Payload - X bytes) I have a Parse function that accepts a byte array and returns a TCPHeader object. It looks like this: TCPHeader Parse( byte[] buffer ); Given the ori...

How do I extract byte array from soapUI response?

I am testing a web service with soapUI. One of the responses looks like this: <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"&gt; <S:Body> <ns2:getInputConfigFilesResponse xmlns:ns2="http://ws.pdb.ericsson.se/"&gt; <return>UEsDBBQACAAIAO1GNToAAAAAAAAAAAAAAAANAAAAc2NyaXB0cy9lbGxza [...] AATAAAAAAAAA...

.NET String to byte Array C#

How do I convert a string to a byte array in .NET (C#)? Update: Also please explain why encoding should be taken into consideration. Can't I simply get what bytes the string has been stored in? Why this dependency on encoding?!!! ...

How do I read text from a serial port?

I am trying to read data off of a Windows serial port through Java. I have the javax.comm libraries and am able to get some data but not correct data. When I read the port into a byte array and convert it to text I get a series of characters but no real text string. I have tried to specify the byte array as being both "UTF-8" and "US-...