0

I want to get the path of a file from _layouts folder in SharePoint 2013, for a stream input.

I tried:

iTextSharp.text.Document doc = new iTextSharp.text.Document(PageSize.A4); 
var path = Server.MapPath(@"\15\TEMPLATE\LAYOUTS\wfcourrierdep\images\LettreI.png");
var output = new FileStream(path, FileMode.Create);
var writer = PdfWriter.GetInstance(doc, output);
doc.Open();

And

iTextSharp.text.Document doc = new iTextSharp.text.Document(PageSize.A4);
var path = SPUtility.GetCurrentGenericSetupPath(@"TEMPLATE\LAYOUTS\wfcourrierdep\pdf\Dictionnaire.pdf");
var output = new FileStream(path, FileMode.Create);
var writer = PdfWriter.GetInstance(doc, output);
doc.Open();

No result

I want to use the GetCurrentGenericSetupPath or GetVersionedGenericSetupPath but I don't know what is the format of my URL I should pass in.

  • Are you trying this from a WebPart? – Amal Hashim Jan 26 '15 at 17:38
  • no from an application page – ezzaam Jan 26 '15 at 17:39
0

You can modify your code as below

 var path = SPUtility.GetCurrentGenericSetupPath(@"TEMPLATE\LAYOUTS\wfcourrierdep\pdf\Dictionnaire.pdf");
  • this is what i made – ezzaam Jan 26 '15 at 17:57
  • 1
    Try to output the path and check it is having the correct value. What exception/error you are getting – Amal Hashim Jan 26 '15 at 18:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.