Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Text displays as Byte[]

2007-06-05
2013-04-09
  • DarkShadow81
    DarkShadow81
    2007-06-05

    as long as you want to save binary data in a blobb you can convert the byte array to base64 and store sthe base64string in the blobb.reconverting at the same way

    some short sample as i need it:

    Loading from BLOB Field:

    string Tmp = myReader.GetString(3);
    byte[] rawData = new byte[FileSize];   
    rawData = System.Convert.FromBase64String(Tmp);

    Saving into BLOB Field:

    UInt32 FileSize; byte[] rawData; FileStream fs;
    fs = new FileStream(@Datei, FileMode.Open, FileAccess.Read);           
    FileSize = System.Convert.ToUInt32(fs.Length);
    rawData = new byte[FileSize];
    fs.Read(rawData, 0, (int)FileSize);
    fs.Close();
    string str = System.Convert.ToBase64String(rawData,0,(int)FileSize);

    compiled and test with images, and it works fine :-)