0

My old signature was

protected override bool SendFiles(ITransactionStep configuration, FileInfo xml)

Thus I was working with doing this

using (var blobStream = GetBlobStream(arg.Configuration, arg.WorkspaceContext, arg.TempFile.Length, out var blob))
using (var tempData = xml.OpenRead())

However now I am switching from FileInfo to XElement

protected override bool SendFiles(ITransactionStep configuration, XElement xml)

Goal is to stream in the XElement and Write to fileshare

Thus I cannot use this

xml.OpenRead())  // Can't do that

Should I be doing an Steam .. . with xmlstreamwriter or streamwriter or streamreader? How can I stream this XElement into memory to write to a fileshare ?

  • `XElement` is already completely in memory. From the [docs](https://learn.microsoft.com/en-us/dotnet/standard/linq/linq-xml-overview): *LINQ to XML provides an **in-memory** XML programming interface that leverages the .NET Language-Integrated Query (LINQ) Framework. LINQ to XML uses .NET capabilities and is comparable to an updated, redesigned Document Object Model (DOM) XML programming interface.* But perhaps you have an [XY problem](https://meta.stackexchange.com/q/66377) here, maybe you can explain what you are trying to do? – dbc Dec 14 '20 at 19:19
  • Ok - yes true it is already in memory - So I need to write that XElement to blobstorage , the old code arg.TempFile.OpenRead() which is essentially FilePath.OpenRead() , but essentially the xml.OpenRead() is not a method - so if I'm wanting to take this XElement and stream it to fileshare - all these old methods and properties for FileInfo like .Length, .OpenRead() , .CopyTo(blobStream) are needing replaced – Jeremy Miller Dec 14 '20 at 20:02
  • Then can you please [edit] your question to make it clear what you are asking? Is your question, *How can I [save](https://learn.microsoft.com/en-us/dotnet/api/system.xml.linq.xelement.save?view=net-5.0#System_Xml_Linq_XElement_Save_System_IO_Stream_) an `XElement` to a `Stream`?* Or is it something else? – dbc Dec 14 '20 at 20:14
  • Ok - yes that is what I think I want to do. It was that I was switching some existing code out and trying to backfill it / retro fit with the new change. – Jeremy Miller Dec 14 '20 at 20:16
  • Then you can use [`Save()`](https://learn.microsoft.com/en-us/dotnet/api/system.xml.linq.xelement.save?view=net-5.0#System_Xml_Linq_XElement_Save_System_IO_Stream_) or [`SaveAsync()`](https://learn.microsoft.com/en-us/dotnet/api/system.xml.linq.xelement.saveasync?view=net-5.0). – dbc Dec 14 '20 at 20:18

0 Answers0