zoukankan      html  css  js  c++  java
  • ArcGIS Pro 读写BLOB字段

     public async Task WriteBlobField(Table table, string blobFieldName, string imageFileName)
        {
          await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
          {
            // Read the image file into a MemoryStream
            MemoryStream memoryStream = new MemoryStream(); ;
            using (FileStream imageFile = new FileStream(imageFileName, FileMode.Open, FileAccess.Read))
            {
              imageFile.CopyTo(memoryStream);
            }
    
            // Create a new row in the table, and write the Memory Stream into a blob fiele
            using (RowBuffer rowBuffer = table.CreateRowBuffer())
            {
              rowBuffer[blobFieldName] = memoryStream;
              table.CreateRow(rowBuffer).Dispose();
            }
          });
        }
    
        #endregion
    
        #region Reading a Blob field
    
        public async Task ReadBlobField(Table table, QueryFilter queryFilter, string blobFieldName)
        {
          await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
          {
            const string imageFileBaseName = "C:\path\to\image\directory\Image";
    
            // for each row that satisfies the search criteria, write the blob field out to an image file
            using (RowCursor rowCursor = table.Search(queryFilter))
            {
              int fileCount = 0;
              while (rowCursor.MoveNext())
              {
                using (Row row = rowCursor.Current)
                {
                  // Read the blob field into a MemoryStream
                  MemoryStream memoryStream = row[blobFieldName] as MemoryStream;
    
                  // Create a file
                  using (FileStream outputFile = new FileStream(imageFileBaseName + fileCount.ToString(), FileMode.Create, FileAccess.Write))
                  {
                    // Write the MemoryStream into the file
                    memoryStream.WriteTo(outputFile);
                  }
                }
              }
            }
          });
        }
  • 相关阅读:
    python开发初识函数:函数定义,返回值,参数
    py基础2--列表,元祖,字典,集合,文件
    python中的urlencode与urldecode
    使用pymysql进行mysql数据库操作
    docker 命令
    docker镜象
    docker的安装
    JS中的prototype(原文地址:http://www.cnblogs.com/yjf512/archive/2011/06/03/2071914.html)
    linux远程复制和压缩文件的命令
    rosbag 初尝试
  • 原文地址:https://www.cnblogs.com/gisoracle/p/12551959.html
Copyright © 2011-2022 走看看