using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using Telerik.Web.UI;

public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void RadEditor1_ExportContent(object sender, EditorExportingArgs e)
    {
        string url = String.Format("~/{0}.docx", RadEditor1.ExportSettings.FileName);
        string path = Server.MapPath(url);

        if (File.Exists(path))
        {
            File.Delete(path);
        }

        using (FileStream fs = File.Create(path))
        {
            Byte[] info = System.Text.Encoding.Default.GetBytes(e.ExportOutput);
            fs.Write(info, 0, info.Length);
        }

        e.Cancel = true;
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        RadEditor1.ExportToDocx();
    }
}