Groups | Blog | Home
all groups > vb.net > february 2005 >

vb.net : System.IO.FileNotFoundException: imagefile.bmp


Jeremy Olmstead
2/22/2005 8:42:33 PM
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.

Herfried K. Wagner [MVP]
2/22/2005 10:07:15 PM
Jeremy,

"Jeremy Olmstead" <jolmstead1-@-charter.net> schrieb:
[quoted text, click to view]

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), ...)
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
AddThis Social Bookmark Button