Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15083

VS 2017 How do you get path to an image stored in resources

$
0
0
I have put various files into my application's Resources (pic1, pic2, pic3, etc.). Random images are placed into a picturebox control (pbxPic) on my form. When I click a button I want to identify the path to the picture file being displayed in pbxPic.

I noticed that in the Resources.resx file that each entry has a <value> associated with it that identifies the path.
Code:

... 
  <data name="pic1" type="System.Resources.ResXFileRef, System.Windows.Forms">
    <value>..\Resources\pic1.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
  </data>
  <data name="pic2" type="System.Resources.ResXFileRef, System.Windows.Forms">
    <value>..\Resources\pic2.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
  </data>
  <data name="pic3" type="System.Resources.ResXFileRef, System.Windows.Forms">
    <value>..\Resources\pic3.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
  </data>

I was thinking that I could capture the associated value when I loaded the associated resource into my picturebox, but I do not know how to reference it. So for example
Code:

dim PicPath as string

pbxPic.image = My.Resources.pic1
PicPath = ????????


Viewing all articles
Browse latest Browse all 15083

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>