How to extract a Word document from an URL and duplicate it in my C# page
Posted on 2007-10-12
Upon page load, my page should take an often-updated Word policy document residing at our sister organization's URL and reproduce it in my C# page--
--appending a button the user can click to acknowledge having read the policy and get their acceptance recorded in our own database.
The part involving the button is easy; on the other hand, I'm trying to figure out how to reproduce the Word .doc.
I know how to reproduce an HTML file via streamreader, probably could do a txt file the same way. But how to copy a proprietary file such as a .doc ? Alien characters pop up.
Here's the page-load code I used in my cs, until my boss clarified she needed the .DOC from the directory instead of the HTML file by the same name:
public partial class _Default : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
//read file from URL
//write file to user's viewing location
System.Text.StringBuilder sbuild = new StringBuilder();
string temp = "";
StreamReader webstream = new StreamReader(WebRequest.Create("http: ( ***Our buddy organization*** ) .html").GetResponse().GetResponseStream());
while ((temp = webstream.ReadLine()) != null)
sbuild.Append(temp + "\r\n");
lblPolicy.Text = sbuild.ToString();