Loading word file from url

I’m trying to load a word document from an url like so

try
{
    // Get the web response 
    HttpWebResponse MyResponse = (HttpWebResponse)MyRequest.GetResponse();
    // Make sure the response is valid 
    if (HttpStatusCode.OK == MyResponse.StatusCode)
    {
        // Open the response stream 
        using (Stream MyResponseStream = MyResponse.GetResponseStream())
        {
            wordTemplateDocument = new Document(MyResponseStream);
        }
    }
}
catch (Exception err)
{
    throw new Exception("Error reading file from URL: " + err.Message, err);
}

But I get an error about the stream not being seekable. I there any way to load a file from url without intermediate files?. I tried all kinds of buffers and such but they all result in crc errors or messages like zip file(docx) to short

I can answer myself

try
{
    // Get the web response 
    HttpWebResponse MyResponse = (HttpWebResponse)MyRequest.GetResponse();
    // Make sure the response is valid 
    if (HttpStatusCode.OK == MyResponse.StatusCode)
    {
        // Open the response stream 
        using (Stream MyResponseStream = MyResponse.GetResponseStream())
        {
            Stream TResponseStream = new MemoryStream();
            // Create a 4K buffer to chunk the file 
            byte[] MyBuffer = new byte[4096];
            int BytesRead;
            // Read the chunk of the web response into the buffer 
            while (0 < (BytesRead = MyResponseStream.Read(MyBuffer, 0, MyBuffer.Length)))
            {
                // Write the chunk from the buffer to the file 
                TResponseStream.Write(MyBuffer, 0, BytesRead);
            }
            wordTemplateDocument = new Document(TResponseStream);
        }
    }
}
catch (Exception err)
{
    throw new Exception("Error reading file from URL: " + err.Message, err);
}

Aspose words will read fine from a memory stream. Still if anyone knows a shorter way please let me know!

Hi
Thanks for your request. Please try using the following code;

string url = "http://localhost/test_setLicense/in.doc";
// Prepare the web page we will be asking for
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "GET";
request.ContentType = "application/msword";
request.UserAgent = "Mozilla/4.0+(compatible;+MSIE+5.01;+Windows+NT+5.0";
// Execute the request
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
// We will read data via the response stream
Stream resStream = response.GetResponseStream();
// Write content into the MemoryStream
BinaryReader resReader = new BinaryReader(resStream);
MemoryStream docStream = new MemoryStream(resReader.ReadBytes((int)response.ContentLength));
// Create document
Document doc = new Document(docStream);
// Save document
doc.Save(@"Test048\out.doc");

Hope this helps.
Best regards.