使用iTextSharp。错误 - “指定的路径,文件名或两者都太长。完全限定的文件名必须少于260个字符,目录名必须少于248个字符。
问题描述:
使用itextsharp。我收到此错误指定的路径,文件名或两者都太长。完全限定的文件名必须少于260个字符,目录名称必须少于248个字符。请帮我过来。
代码片段:
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:
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();
}
答
windows有一个路径限制为260个字符,请尝试将项目移动到较短的路径(即C:\ MyProject \ ...)。
With Best问候
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
您好,
您只需将项目文件夹从路径复制到根目录(例如:-d: \abc\abc\xyz \YourProject to d:\ YourProject)
最大文件路径长度错误已解决。这个技巧在我的情况下起作用。
谢谢你
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