Reputation: 33
I've created a billing app that creates a pdf. My issue is the pdf doesn't get created because the header for the pdf isn't being fond, i get a "could not find part of the path c#". I've tried changing the location of the folder and also including it in the bin folder.
var imagepath = @System.Reflection.Assembly.GetExecutingAssembly()
.Location + @"\..\..resources\pdfHeader.png";
using (FileStream fs = new FileStream(imagepath, FileMode.Open))
{
var png = Image.GetInstance(System.Drawing.Image.FromStream(fs), ImageFormat.Png);
png.ScalePercent(25f);
png.SetAbsolutePosition(pdfDoc.PageSize.Width - 559f - 2f , pdfDoc.PageSize.Height - 2f - 115f);
pdfDoc.Add(png);
}
Upvotes: 3
Views: 8426
Reputation: 394
The error is pretty self-explanatory, a part of the path is missing (ie. one of the folders in the path doesn't exist). This is most likely caused by this:
\..\..resources\
You forgot a \
before resources
. :)
By the way - please follow naming conventions (here's an official link for C#) for all languages you code in. Your variable should be called imagePath
.
Hope I could help!
Upvotes: 3