Click here to Skip to main content
16,012,153 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Am using itextsharp. I got this error "The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.". Please help me to over come this.

Code Snippet:

C#
protected void ExportHTMLtoPDF()
{
    Response.ContentType = "application/pdf";
    Response.AddHeader("content-disposition", "attachment;filename=" + HttpContext.Current.Session["StudentID"].ToString() + ".pdf");
    Response.Cache.SetCacheability(HttpCacheability.NoCache);
    StringWriter sw = new StringWriter();
    HtmlTextWriter hw = new HtmlTextWriter(sw);
    frmPrint.RenderControl(hw);
    StringReader sr = new StringReader(sw.ToString());
    Document pdfDoc = new Document(PageSize.A3, 0f, 0f, 0f, 0f);
    HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
    PdfWriter writer;
    PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
    pdfDoc.Open();
    pdfDoc.Close();
    Response.Write(pdfDoc);
    Response.End();
}
Posted
Updated 16-Apr-12 2:20am
v2

Hi,

windows has a path limit of 260 characters, please try to move your project to a shorter path (i.e "C:\MyProject\...").

With Best Regards
 
Share this answer
 
Hello,

you simply need to copy your project folder from your path to root directory (ex:-d:\abc\abc\xyz\YourProject to d:\YourProject )


Maximum file path length Error Solved.this trick work in my case.

thank you
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900