using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using System.IO;
using Telerik.WebControls;

public partial class _Default : System.Web.UI.Page
{
  const string UploadPath = @"C:\MyUploads\";

  protected void Page_Load(object sender, EventArgs e)
  {
    if (!Directory.Exists(UploadPath))
      Directory.CreateDirectory(UploadPath);
  }

  protected void btnUpload_Click(object sender, EventArgs e)
  {
    try
    {
      if (RadUpload1.InvalidFiles.Count == 0)
      {
        foreach (UploadedFile file in RadUpload1.UploadedFiles)
        {
          file.SaveAs(UploadPath + file.GetName(), true);
        }
        lblStatus.Text = "Upload successful.";
      }
      else
      {
        lblStatus.Text = string.Format(
          "There were {0} invalid files.  Download was terminated.",
          RadUpload1.InvalidFiles.Count);
      }
    }
    catch (Exception ex)
    {
      lblStatus.Text = "Error uploaded: " + ex.Message;
    }
  }

}
