|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Problem with System.Drawing.Bitmap()In my form_load() method, I have the following code: sPath = System.IO.Path.GetDirectoryName( _ System.Reflection.Assembly.GetExecutingAssembly().GetName ().CodeBase()) PictureBox1.Image = New System.Drawing.Bitmap(sPath & "\data\pic- logo.gif") Pretty simple code that is supposed to load the pic-logo.gif stored in the Application's directory\data into a picture box on the form. So, let's say my sPath is set to C:\MyDirectory. So, the pic should be pulled from C:\MyDirectory\data\pic-logo.gif, right? Nope! For some reason, the system is placing \ in front of the path name. So, my call is actually coming out as \C:\MyDirectory\Data\pic- logo.gif. I've even tried hard coding the path into the call and it STILL is putting a \ in front of the path. Any idea what might be going on here? Thank You! Anthony
Show quote
Hide quote
On Jul 3, 9:09 am, "Anthony P." <papill***@gmail.com> wrote: Hi,> Hello Everyone, > > In my form_load() method, I have the following code: > > sPath = System.IO.Path.GetDirectoryName( _ > System.Reflection.Assembly.GetExecutingAssembly()..GetName > ().CodeBase()) > > PictureBox1.Image = New System.Drawing.Bitmap(sPath & "\data\pic- > logo.gif") > > Pretty simple code that is supposed to load the pic-logo.gif stored in > the Application's directory\data into a picture box on the form. > > So, let's say my sPath is set to C:\MyDirectory. So, the pic should be > pulled from C:\MyDirectory\data\pic-logo.gif, right? Nope! > > For some reason, the system is placing \ in front of the path name. > So, my call is actually coming out as \C:\MyDirectory\Data\pic- > logo.gif. > > I've even tried hard coding the path into the call and it STILL is > putting a \ in front of the path. > > Any idea what might be going on here? > > Thank You! > Anthony Try using "Application.StartupPath" and combine it with your trailing path. Like: ' If i remember correct... Dim sPath As String sPath = Applicaton.StartupPath & "\data\pic-logo.gif" Application.StartupPath will locate the path wherever your applicaton resides on. Hope it solves, Onur Guzel > Application.StartupPath will locate the path wherever your applicaton Hi Onur,> resides on. > > Hope it solves, > > Onur Guzel- Hide quoted text - Thanks for the response. Unfortunately, that didn't solve it. It's kind of odd because the code I showed above actually pointed to the right place. The problem was that the system was adding a back slash to the path before the pathname. So let's say my path was C:\Program Files\MyProgram\Data\logo.gif, the system was reading it as \C: \Program Files\MyProgram\Data\logo.gif. It was almost like it was expecting a UNC. Ultimately, I simply removed the code and hard coded a location. Obviously, that won't work for deployment though so I do need to solve this. It's REALLY got me baffled! Anthony
structures in VB.Net
vb.net and Ms SQL Connection ? Using "Me" Using WPF with a "normal" windows app DataGridView Event Web server is not running ASP.NET version 1.1. Serializing Custom Generic Collection (Of InterfaceType) Add Line Break to mail body Detect Default namespace (Unkown) Inherited form: prevent the Load-event from firing for inheritors |
|||||||||||||||||||||||