Reputation: 57
.Net 4.5 WPF desktop application, goal is to add an existing image to a pdfSharp doc. First step is getting the path to the image. My image is in an Images folder under my project. I've tried:
String myPath = string.Empty;
myPath = System.IO.Directory.GetCurrentDirectory();
myPath = myPath + "\\Images\\MyImage.png";
myPath ends up being:
C:\\Users\\My User Name\\Documents\\LocalProjects\\MyProject\\MyProject\\bin\\Debug\\Images\\MyImage.png
Then I check using File.Exists in an If statement. It fails.
Thanks!
Upvotes: 0
Views: 241
Reputation: 128013
Make sure that the Build Action
of the image file in your project is set to Content
, and set Copy to Output Directory
to a value other than Do not copy
.
Otherwise the image file (including its relative path) won't be copied to the output directory bin\Debug\
.
Upvotes: 1