Stian Standahl Stian Standahl - 1 year ago 133
C# Question

How to enable seeking in Azure Blob stream

I have a BlobStream that is created from the method OpenWriter.

var blob = CloudContainer.GetBlobReference(name));
if (blob == null)
{
return null;
}

return blob.OpenWrite();


Using this stream i would like to seek or set the position, but each time i do this i get a NotSupportedException. After doing some research i found that the canSeek is set to false, which causes this problem. But, the CanSeek is false only if the length is unknown. But the length is known when i run the debugger.

Why is CanSeek false?
How can i make it set to true?

Answer Source

You can seek within a page blob - there is explicit support for it in BlobWriteStreamBase class.

I think you could also read & write to specified parts of a Block blob using HTTP Range headers, which would be effectively the same thing as seeking. But I think you'd have to implement that yourself.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download