System.IO.FileNotFoundException: imagefile.bmp

  • Thread starter Thread starter Jeremy Olmstead
  • Start date Start date
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
 
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), ...)
///
 
Back
Top