System.IO.FileNotFoundException: imagefile.bmp

J

Jeremy Olmstead

I am having a problem printing an image stored on a system's hard drive.
It works on my development machine, but when transfered to a test machine
it does not work. The image is named wkwlogo.bmp and it is in the "bin"
directory of the project. When I setup the system on the test computer I
just copy the "bin" directory to the test system and execute it. The
relevant line of code is below.

ev.Graphics.DrawImage(Image.FromFile("wkwlogo.bmp"), leftMargin, topMargin)

This results in a System.IO.FileNotFoundException. Any help would be
appreciated.

Jeremy Olmstead
 
H

Herfried K. Wagner [MVP]

Jeremy,

Jeremy Olmstead said:
I am having a problem printing an image stored on a system's hard drive.
It works on my development machine, but when transfered to a test machine
it does not work. The image is named wkwlogo.bmp and it is in the "bin"
directory of the project. When I setup the system on the test computer I
just copy the "bin" directory to the test system and execute it. The
relevant line of code is below.

ev.Graphics.DrawImage(Image.FromFile("wkwlogo.bmp"), leftMargin,
topMargin)

This results in a System.IO.FileNotFoundException. Any help would be
appreciated.

Maybe somewhere the current directory is changed. If your project is a
Windows Forms project, you can try this:

\\\
Imports System.IO
..
..
..
Dim FileName As String = _
Path.Combine(Application.StartupPath, "wkwlogo.bmp")
....(Image.FromFile(FileName), ...)
///
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top