public void getfiles(string dir)
    {
        ddFilesDoc.Items.Clear();

        ListItem li1 = new ListItem();

        li1.Text  = "-- select --";
        li1.Value = "-1";

        ddFilesDoc.Items.Add(li1);

        ArrayList af = new ArrayList();

        string[] Filesdoc = Directory.GetFiles(dir);
        foreach (string file in Filesdoc)
        {
            string appdir   = Server.MapPath("~/App_Uploads_Docs/") + ddCatDoc.SelectedValue;
            string filename = file.Substring(appdir.Length + 1);

            if ((!filename.Contains("_svn")) && (!filename.Contains(".svn")))
            {
                if (filename.ToLower().Contains(".zip") || filename.ToLower().Contains(".doc") || filename.ToLower().Contains(".pdf") || filename.ToLower().Contains(".xls"))
                {
                    ListItem li = new ListItem();
                    li.Text  = filename;
                    li.Value = filename;
                    ddFilesDoc.Items.Add(li);
                }
            }
        }
        UpdatePanel1Doc.Update();
    }
    private void showdoc(string folder, string file)
    {
        atagDoc.Visible = true;
        atagDoc.HRef    = "~/App_Uploads_Docs/" + folder + "/" + file;
        atagDoc.Title   = file;

        UpdatePanel1Doc.Update();
    }
 protected void ddCatDoc_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (ddCatDoc.SelectedIndex > 0)
     {
         ddFilesDoc.Enabled = true;
         getfiles(Server.MapPath("~/App_Uploads_Docs/") + ddCatDoc.SelectedItem.Value);
         UpdatePanel1Doc.Update();
     }
 }
    protected void getcontentdoc()
    {
        if ((Session["catdoc"] != null) && (Session["Filesdoc"] != null))
        {
            ddCatDoc.SelectedValue = Session["catdoc"].ToString().Replace("\\", "/");
            getfiles(Server.MapPath("~/App_Uploads_Docs/") + ddCatDoc.SelectedValue);
            ddFilesDoc.SelectedValue = Session["Filesdoc"].ToString();
            showdoc(ddCatDoc.SelectedValue, ddFilesDoc.SelectedValue);
        }

        UpdatePanel1Doc.Update();
    }
    protected void LinkButton1D_Click(object sender, EventArgs e)
    {
        RadUploadContext upContext = RadUploadContext.Current;

        string dirdoc = Server.MapPath("~/App_Uploads_Docs/");

        if (RadUploadDoc.UploadedFiles.Count > 0)
        {
            foreach (UploadedFile filedoc in RadUploadDoc.UploadedFiles)
            {
                if ((DropDownList1D.SelectedIndex == 0) && (tbDirectoryDoc.Text.Length == 0))
                {
                    Session["catdoc"]   = null;
                    Session["Filesdoc"] = null;
                    TabPanel3Docs.Focus();
                }
                else if ((DropDownList1D.SelectedIndex == 0) && (tbDirectoryDoc.Text.Length > 0))
                {
                    Directory.CreateDirectory(dirdoc + tbDirectoryDoc.Text);
                    filedoc.SaveAs(Server.MapPath("~/App_Uploads_Docs/" + tbDirectoryDoc.Text + "/" + filedoc.GetName()), true);
                    Session["catdoc"]   = tbDirectoryDoc.Text;
                    Session["Filesdoc"] = filedoc.GetName();
                }

                else if ((DropDownList1D.SelectedIndex != 0) && (tbDirectoryDoc.Text.Length > 0))
                {
                    Directory.CreateDirectory(dirdoc + DropDownList1D.SelectedItem.Text + "/" + tbDirectoryDoc.Text);
                    filedoc.SaveAs(Server.MapPath("~/App_Uploads_Docs/" + DropDownList1D.SelectedItem.Text + "/" + tbDirectoryDoc.Text + "/" + filedoc.GetName()), true);
                    Session["catdoc"]   = DropDownList1D.SelectedItem.Text + "/" + tbDirectoryDoc.Text;
                    Session["Filesdoc"] = filedoc.GetName();
                }

                else if ((DropDownList1D.SelectedIndex > 0) && (tbDirectoryDoc.Text.Length == 0))
                {
                    filedoc.SaveAs(Server.MapPath("~/App_Uploads_Docs/" + DropDownList1D.SelectedItem.Text + "/" + filedoc.GetName()), true);

                    Session["catdoc"]   = DropDownList1D.SelectedItem.Text;
                    Session["Filesdoc"] = filedoc.GetName();
                }
            }
        }


        getfolders(ref al, Server.MapPath("~/App_Uploads_Docs/"));

        UpdatePanel1Doc.Update();
        UpdatePanel2Doc.Update();
        getcontentdoc();
    }