Write large amount of bytes...

Discussion in 'Programming & Scripting' started by tOxiC x, Feb 24, 2009 with 5 replies and 200 views.

  1. tOxiC x

    tOxiC x Member

    Messages:
    656
    Ratings:
    116
    I need to write a large amount of bytes that I have.


    I can't declare a new byte because the value is too long. It's about 300 bytes I need it to write. Anyone know of a way to declare these bytes?
     
  2. zadesa

    zadesa Enthusiast

    Messages:
    75
    Ratings:
    43
    byte[] buffer = new byte[300];
    buffer = assignvalueherelolz;
    ? (: that should take 300 easyily lul.
     
  3. Luxurious Meat

    Luxurious Meat Getting There

    Messages:
    615
    Ratings:
    120
    I think I know what you want to do. You want to declare a large, static byte array. I've had this same issue all I did was find a file with the data already in it and made an app to create the field definition for me, lol.
     
    • Like Like x 1
  4. OP
    tOxiC x

    tOxiC x Member

    Messages:
    656
    Ratings:
    116
    Lol, smart... Thanks.
    BTW: zedesa that won't work for what I'm doing.
     
  5. Luxurious Meat

    Luxurious Meat Getting There

    Messages:
    615
    Ratings:
    120
    Heh, heres an example:
    Code:
    int count = 4;
    
    string[] hexDigits = BitConverter.ToString(IO.In.ReadBytes(count, IOHelper.ByteOrder.LittleEndian)).Split(new char[] { '-' });
    
    string fieldDef = "static byte[] fieldName = new byte[" + count.ToString() + "] {";
    for (int x = 0; x < hexDigits.Length; x++)
    fieldDef += (x != hexDigits.Length - 1) ? "0x" + hexDigits[x]  + ", " : " 0x" + hexDigits[x] + " };";
    
     
  6. zadesa

    zadesa Enthusiast

    Messages:
    75
    Ratings:
    43
    then i dont get wat your doing lulz