private void dowToolStripMenuItem_Click(object sender, EventArgs e) { var selectedContainerNode = treeView1.SelectedNode; var selectedTreeNode = treeViewStorageObjects.SelectedNode; saveFileDialog1.RestoreDirectory = true; if (selectedContainerNode == null || selectedTreeNode == null) { return; } if (saveFileDialog1.ShowDialog(this) != DialogResult.OK) { return; } StorageItem storageObject = Connection.GetStorageItem(selectedContainerNode.Text, selectedTreeNode.Text); FileStream fs = new FileStream(saveFileDialog1.FileName, FileMode.Create); byte[] buffer = new byte[4096]; int amt; while ((amt = storageObject.ObjectStream.Read(buffer, 0, buffer.Length)) != 0) { fs.Write(buffer, 0, amt); } //This is REQUIRED! fs.Flush(); fs.Close(); storageObject.Dispose(); }
public void Should_return_partial_content_when_optional_range_header_is_specified() { StorageItem si = null; try { var requestHeaders = new Dictionary <RequestHeaderFields, string>(); requestHeaders.Add(RequestHeaderFields.Range, "0-5"); connection.CreateContainer(Constants.CONTAINER_NAME); connection.PutStorageItem(Constants.CONTAINER_NAME, Constants.StorageItemName); si = connection.GetStorageItem(Constants.CONTAINER_NAME, Constants.StorageItemName, requestHeaders); } finally { if (si != null) { si.Dispose(); } connection.DeleteStorageItem(Constants.CONTAINER_NAME, Constants.StorageItemName); connection.DeleteContainer(Constants.CONTAINER_NAME); } }
public void TearDown() { storageItem.Dispose(); }