QueuedTask.Run(() =>
{
var editOp = new EditOperation() { Name = "Blob Cursor" };
var featLayer = MapView.Active.Map.FindLayers("Hydrant").First() as FeatureLayer;
editOp.Callback((context) =>
{
using (var rc = featLayer.GetTable().Search(null, false))
{
while (rc.MoveNext())
{
using (var record = rc.Current)
{
//read the blob field and save to a file
var msw = new MemoryStream();
msw = record["BlobField"] as MemoryStream;
using (FileStream file = new FileStream(@"d:\temp\blob.jpg", FileMode.Create, FileAccess.Write))
{
msw.WriteTo(file);
}
//read file into memory stream
var msr = new MemoryStream();
using (FileStream file = new FileStream(@"d:\images\Hydrant.jpg", FileMode.Open, FileAccess.Read))
{
file.CopyTo(msr);
}
//put the memory stream in the blob field and save to feature
record["BlobField"] = msr;
record.Store();
}
}
}
}, featLayer.GetTable());
if (!editOp.IsEmpty)
{
var result = editOp.Execute(); //Execute and ExecuteAsync will return true if the operation was successful and false if not
}
});