How can I download a .docx file?

Sls 1 Reputation point
2022-02-16T17:33:52.253+00:00

Hi there,

I'm trying to download a .docx file, but I don't have the application for it. I don't want to open the file, I just want to download it as a .docx. I don't have OneDrive either. Every time I try to download it, it downloads as a XML. This ruins all the formatting put into the file. How can I download the .docx format?

Office Management
Office Management
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Management: The act or process of organizing, handling, directing or controlling something.
2,147 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Viorel 1 Reputation point
    2022-03-22T02:27:59.7+00:00

    If you do not mind using a 3rd party library, you can download Spire.Doc (also available on NuGet) and referce the DLLs in your project, and use the following C# code snippet to donwload a Word document from a URL.

    using Spire.Doc;
    using System.IO;
    using System.Net;
    
    namespace DownloadfromURL
    {
        class Program
        {
            static void Main(string[] args)
            {
                Document doc = new Document();
                WebClient webClient = new WebClient();
                using (MemoryStream ms = new MemoryStream(webClient.DownloadData("document's url")))
                {
                    doc.LoadFromStream(ms, FileFormat.Docx);
                }
                doc.SaveToFile("result.docx", FileFormat.Docx);
            }
        }
    }
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.