Abhineet Srivastava

Abhineet Srivastava

  • NA
  • 890
  • 95.1k

How to Delete Subfolder in .cs page

Jul 29 2013 7:36 AM
Hi,
I am saving the file using this Method-

 public void SaveDialog(string template, string visatypeid, string folderName, string fileType)
    {
        string filePath = Server.MapPath("" + folderName + "/" + visatypeid + "/" + fileType + "/" + template + "");
        System.IO.FileInfo targetFile = new System.IO.FileInfo(filePath);
        FileInfo objFileInfo = default(FileInfo);

        try
        {
            objFileInfo = new FileInfo(filePath);

            if (objFileInfo.Exists)
            {

                Response.Clear();

                Response.Cache.SetCacheability(System.Web.HttpCacheability.Private);

                Response.AddHeader("Content-Disposition", "attachment; filename=" + objFileInfo.Name);

                Response.AddHeader("Content-Length", objFileInfo.Length.ToString());

                Response.ContentType = "application/octet-stream";
                Response.WriteFile(filePath);
                Response.End();
            }
            else
            {
                Type cstype = this.GetType();
                ClientScriptManager cs = Page.ClientScript;
                cs.RegisterStartupScript(cstype, "onLoadCall", "<script>alert('Template does not exist.'); window.location.href=window.location.href;</script>", false);
            }
        }
        catch (Exception ex)
        {
            //MsgBox("error")
        }
    }


File Is Saving like that--Casefile/608/Document/file.txt Formate.

Now,i have to delete the subfolder menas--608/Document/File.txt


Anyone have a idea about how to do  it?










Answers (5)