I have seen this post How to correctly open a FileStream for usage with an X开发者_运维知识库Document but it doesn't help me since I don't have the path to the file on the local hard drive. This XDocument is getting passed to another computer so the BaseURI is worthless.
I want to know how to convert an XDocument into a FileStream without using a local file path.
A FileStream
is used to write directly to a file, so if you don't have a file path, you don't have a FileStream
.
You can, however, write to other streams, like a MemoryStream
:
using (var stream = new MemoryStream())
{
yourDocument.Save(stream);
}
精彩评论