Click here to Skip to main content
15,881,281 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I can use this code to print this image:

Quote:
sImage.Format("data_matrix\\bmp\\1.bmp");


Works great. My problem is, I have the image 000001.bmp and 000002.bmp and so forth. If I try to print

Quote:
sImage.Format("data_matrix\\bmp\\000001.bmp");


It doesnt find the image even though its in that folder. Is there an easy solution?

What I have tried:

I tried \0 must be an escape sequence. Im not sure how to work around it.
Posted
Updated 15-Nov-20 20:17pm
Comments
Rick York 16-Nov-20 0:13am    
Those are both relative paths. Are you certain they are valid in all cases?
Shao Voon Wong 16-Nov-20 0:57am    
There is nothing wrong with your code. A common mistake with image assets is the files are added to the project folder but forgotten to add to the debug or release output folder, so the program runs fine in Visual Studio but fails to load the image when the executable is launched elsewhere.

1 solution

You need the complete path, because your exe is running in some directory from which your relative path to the bmps may be invalid.

Use GetCurrentDirectory to see where your exe is running.

The "easy fix" is to copy the files into the exe directory.
 
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