<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Read string stored in Blob field in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/read-string-stored-in-blob-field/m-p/635713#M17126</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Think it should be:&amp;nbsp;&amp;nbsp;&amp;nbsp;(blobText as ESRI.ArcGIS.esriSystem.IMemoryBlobStreamVariant).ExportToVariant(out blobObject);&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 29 Oct 2018 19:38:24 GMT</pubDate>
    <dc:creator>EricO_Neal1</dc:creator>
    <dc:date>2018-10-29T19:38:24Z</dc:date>
    <item>
      <title>Read string stored in Blob field</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/read-string-stored-in-blob-field/m-p/635712#M17125</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm posting this here in case anyone else comes across this and needs a solution to reading string data stored in blobs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First, i understand that this isn't the best method to be storing string/long text format, but it was best for my method and i suspect i'm not the only one who will want to do this!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my case, i was required to store large text blocks into a geodatabase and wanted to keep everything contained into one simple row per-object.&lt;/P&gt;&lt;P&gt;I wasn't interested in either creating multiple rows to store a max of 255 chars or storing in another DB, so based on this i was able to store all my text in a Blob format.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was a little stumped on how to read back this information in C# (python was a breeze), and there wasn't very much help i could find online for this.&lt;/P&gt;&lt;P&gt;So, with that in mind, the code below (with a little massaging) should be able to return a string store in a blob to a string type in C# if anyone is stuck.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c#" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14111421743272277" jivemacro_uid="_14111421743272277" modifiedtitle="true"&gt;
&lt;P&gt;private string getBlobText(IRow row, int blobrowint)&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //blobrowint is the integer location of the blobfield&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ESRI.ArcGIS.esriSystem.IMemoryBlobStream2 blobText = (ESRI.ArcGIS.esriSystem.IMemoryBlobStream2)row.get_Value(blobrowint);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //creates a byte object equal to the size of the blob string&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int n = (int)blobText.Size;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; byte[] blobBytes = new Byte&lt;N&gt;;&lt;/N&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //creates a variant of the blobtext as a object&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; object blobObject = null;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (commenttxt as ESRI.ArcGIS.esriSystem.IMemoryBlobStreamVariant).ExportToVariant(out blobObject);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //converts the blobObject to a byte&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; blobBytes = (byte[])blobObject;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //translates the bytes to string&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; string res = System.Text.Encoding.UTF8.GetString(blobBytes);&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Sep 2014 16:07:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/read-string-stored-in-blob-field/m-p/635712#M17125</guid>
      <dc:creator>CodyScott</dc:creator>
      <dc:date>2014-09-19T16:07:11Z</dc:date>
    </item>
    <item>
      <title>Re: Read string stored in Blob field</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/read-string-stored-in-blob-field/m-p/635713#M17126</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Think it should be:&amp;nbsp;&amp;nbsp;&amp;nbsp;(blobText as ESRI.ArcGIS.esriSystem.IMemoryBlobStreamVariant).ExportToVariant(out blobObject);&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Oct 2018 19:38:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/read-string-stored-in-blob-field/m-p/635713#M17126</guid>
      <dc:creator>EricO_Neal1</dc:creator>
      <dc:date>2018-10-29T19:38:24Z</dc:date>
    </item>
    <item>
      <title>Re: Read string stored in Blob field</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/read-string-stored-in-blob-field/m-p/635714#M17127</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Eric,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry that is correct. It should be blobText.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Oct 2018 19:55:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/read-string-stored-in-blob-field/m-p/635714#M17127</guid>
      <dc:creator>CodyScott</dc:creator>
      <dc:date>2018-10-29T19:55:14Z</dc:date>
    </item>
  </channel>
</rss>

