none
how to get the name of the image in Picture box

    Question

  • Hi

    i have a small problem.I saving an image that is displaying in the picture box. i already has a default image in the picture box before capturing the image from a webcam name default.jpg

    my problem is i want to know the name of the image so that i will ensure whether i'm saving  the newly captured image or the default image. hope i conveyed my problem correctly.looking forward for a solution

    -regards

    GRK

    Tuesday, September 12, 2006 9:01 AM

Answers

  •  GRK wrote:

    ... and also there i no tag member to that.

     

    It's impossible. I tested a VB.net project and added a button there.



        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Me.PictureBox1.Image = Image.FromFile("D:\\test.jpg", True)
            Me.PictureBox1.Image.Tag = "File path: d:\\test.jpg"
            MessageBox.Show(Me.PictureBox1.Image.Tag.ToString())
        End Sub

     

    And it works fine.

    Hope this helps.

    Tuesday, September 12, 2006 9:56 AM

All replies

  • You can store the file name information in the Tag object, something like this:



    pictureBox1.Image = Image.FromFile(@"D:\test.jpg", true);
    pictureBox1.Image.Tag = @"d:\test.jpg";

     

    Then the Image.Tag property can be retrieved as a symbol whether it's a default image or not, of course you can store any other information in the Tag property.

    Hope this helps.

    Tuesday, September 12, 2006 9:23 AM
  • HI thanks for immediate reply.

         i checked with the above code in vb.net it is giving error when i put a @ symbol like the above. and also there i no tag member to that.

     

    Tuesday, September 12, 2006 9:31 AM
  • I forgot to say that the code above is in C#. '@' symbol is used to prevent the '\' transformation. It can equally be replaced with "d:\\test.jpg". It doesn't matter.
    Tuesday, September 12, 2006 9:43 AM
  •  GRK wrote:

    ... and also there i no tag member to that.

     

    It's impossible. I tested a VB.net project and added a button there.



        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Me.PictureBox1.Image = Image.FromFile("D:\\test.jpg", True)
            Me.PictureBox1.Image.Tag = "File path: d:\\test.jpg"
            MessageBox.Show(Me.PictureBox1.Image.Tag.ToString())
        End Sub

     

    And it works fine.

    Hope this helps.

    Tuesday, September 12, 2006 9:56 AM
  • I also checked with the above but i'm unable to set the tab property to the image as in vb.net it is not there in system.drawing.

    now i'll cleary describe my problem.

               i have a registartion application.

              in that form i'm filling the user details along with the photo while taking the registration the picturebox displays the default.jpg.

             after capturing the image using the webcam this will change.

             now when i have to save the record. to prevent the user to save the record without capturing the image i have to check that the picture box contains the default.jpg or the new captured image so i need to get the name of the picture box.

    hope now you can understand what my problem is

    -GRK

    Tuesday, September 12, 2006 10:14 AM