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...
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...
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...
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...
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?
...
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...
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.
...
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.
...
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"];...
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...
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?
...
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...
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"]);
?
...
How can I convert a bitmap to a byte array in c++ WITHOUT the .net framework?
...
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...
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);
...
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...
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/">
<S:Body>
<ns2:getInputConfigFilesResponse xmlns:ns2="http://ws.pdb.ericsson.se/">
<return>UEsDBBQACAAIAO1GNToAAAAAAAAAAAAAAAANAAAAc2NyaXB0cy9lbGxza [...] AATAAAAAAAAA...
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?!!!
...
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-...