Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Name of Image

Name of Image

Scheduled Pinned Locked Moved C#
question
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    humayunlalzad
    wrote on last edited by
    #1

    Hey Guys I have a pictureBox which gets its Image from the Resources file. And I have a label where I want to display the name of the Image (which is a .jpg Image). How do I get the name of the Image from the Image file without the .jpg extension. I want the lblInfo to display Cow in this case.

    pictureBox1.Image = Resources.Cow; //jpg image Cow.jpg
    // lblInfo.Text =

    B H X 3 Replies Last reply
    0
    • H humayunlalzad

      Hey Guys I have a pictureBox which gets its Image from the Resources file. And I have a label where I want to display the name of the Image (which is a .jpg Image). How do I get the name of the Image from the Image file without the .jpg extension. I want the lblInfo to display Cow in this case.

      pictureBox1.Image = Resources.Cow; //jpg image Cow.jpg
      // lblInfo.Text =

      B Offline
      B Offline
      Bottomless Wisdom
      wrote on last edited by
      #2

      // first import System.IO namespace and then use this one.... lblInfo.Text = Path.GetFileNameWithoutExtension("path of image file");

      Software Development & Web Development is my addiction. I am a Visual C# 2.0 and ASP.NET 2.0 Developer and working in Visual Studio 2005 using Dot Net Framework 2.0. Email: bottomless.wisdom@hotmail.com Web: http://bottomless-wisdom.spaces.live.com

      H 1 Reply Last reply
      0
      • B Bottomless Wisdom

        // first import System.IO namespace and then use this one.... lblInfo.Text = Path.GetFileNameWithoutExtension("path of image file");

        Software Development & Web Development is my addiction. I am a Visual C# 2.0 and ASP.NET 2.0 Developer and working in Visual Studio 2005 using Dot Net Framework 2.0. Email: bottomless.wisdom@hotmail.com Web: http://bottomless-wisdom.spaces.live.com

        H Offline
        H Offline
        humayunlalzad
        wrote on last edited by
        #3

        Path.GetFileNameWithoutExtension() method needs a string. And the file which I have included in the Resources file is an Image. How do I give Path.GetFileNameWithoutExtension() a string. I have included the file in the Resources.resx file.

        1 Reply Last reply
        0
        • H humayunlalzad

          Hey Guys I have a pictureBox which gets its Image from the Resources file. And I have a label where I want to display the name of the Image (which is a .jpg Image). How do I get the name of the Image from the Image file without the .jpg extension. I want the lblInfo to display Cow in this case.

          pictureBox1.Image = Resources.Cow; //jpg image Cow.jpg
          // lblInfo.Text =

          H Offline
          H Offline
          humayunlalzad
          wrote on last edited by
          #4

          How can you get an Image Location from an Image object. If that makes it simpler.

          1 Reply Last reply
          0
          • H humayunlalzad

            Hey Guys I have a pictureBox which gets its Image from the Resources file. And I have a label where I want to display the name of the Image (which is a .jpg Image). How do I get the name of the Image from the Image file without the .jpg extension. I want the lblInfo to display Cow in this case.

            pictureBox1.Image = Resources.Cow; //jpg image Cow.jpg
            // lblInfo.Text =

            X Offline
            X Offline
            Xmen Real
            wrote on last edited by
            #5

            its not possible to get the name from an Image object. You have to code for this. Something like pictureBox1.Image = Image.FromFile("ImagePath"); pictureBox1.Tag = "ImagePath"; now whenever you need the path, just parse the Tag property of PB. In your situation, you may use this

            Application.StartupPath + "\\Cow.jpg";

            noway to get the path from an Image object AFAIK

            TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L %^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2 W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN% Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i’TV.C\y<pŠjxsg-b$f4ia> -------------------------------------------------------- 128 bit encrypted signature, crack if you can

            H 1 Reply Last reply
            0
            • X Xmen Real

              its not possible to get the name from an Image object. You have to code for this. Something like pictureBox1.Image = Image.FromFile("ImagePath"); pictureBox1.Tag = "ImagePath"; now whenever you need the path, just parse the Tag property of PB. In your situation, you may use this

              Application.StartupPath + "\\Cow.jpg";

              noway to get the path from an Image object AFAIK

              TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L %^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2 W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN% Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i’TV.C\y<pŠjxsg-b$f4ia> -------------------------------------------------------- 128 bit encrypted signature, crack if you can

              H Offline
              H Offline
              humayunlalzad
              wrote on last edited by
              #6

              Thanx a lot, thats exactly what I wanted to know. Even though I am not very happy, that the Image object does not return the path or the name of the Image.

              X 1 Reply Last reply
              0
              • H humayunlalzad

                Thanx a lot, thats exactly what I wanted to know. Even though I am not very happy, that the Image object does not return the path or the name of the Image.

                X Offline
                X Offline
                Xmen Real
                wrote on last edited by
                #7

                hmmm....i see how happy you are by voting 1 rate :confused:

                TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L %^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2 W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN% Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i’TV.C\y<pŠjxsg-b$f4ia> -------------------------------------------------------- 128 bit encrypted signature, crack if you can

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups